python - Adding numbers to a list when prompted -
this question has answer here:
- how can read inputs integers? 14 answers
i trying append numbers list created when prompted number.
here code have far.
x = [1, 2, 3, 4, 5] y = raw_input("enter number: ") numbers in y: if y > 5: x.append(y) print x else: print "list remains same"
but, if type in 3, still appends list.
this 1 way in python 2:
x = [1,2,3,4,5] y = int(raw_input("enter number: ")) if (y) > 5: x.append(y) print x else: print "list remains same"
Comments
Post a Comment