python - Adding numbers to a list when prompted -


this question has answer here:

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

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -