Reputation: 1
I am trying to create an empty list and for some reason it is telling me it's invalid syntax? it also flags the next line with the same error, saying that while count<amount: is invalid. am i wrong for thinking this doesnt make sense? using vsc. thanks in advance. my code looks like this.
list=[]
count=0
while count < amount :
s=int(input"enter a number:")
list.append(s)
count= count+1
i tried to use list={}, list=() even though i know those are wrong. it also flags lines like list4=[1,3] ??
Upvotes: 0
Views: 247
Reputation: 404
In python the indent is 4 spaces.
You need to change the variable name "list" because it is a built in name in python.
You need to put brackets after input.
amount = 5
numberList = []
count = 0
while count < amount:
s = int(input("enter a number:"))
numberList.append(s)
count += 1
Upvotes: 2
Reputation: 1072
amount
is not defined. Define it with a number like 5 and try then.
You also need to make sure the variable list
is called something else, it is a python-reserved word.
Lastly, make sure the input
function has parenthesis ()
around it. e.x. input("enter number: ")
Upvotes: 2