Python Forum
How to make a variable contain multiple values - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: How to make a variable contain multiple values (/thread-26334.html)

Pages: 1 2


RE: How to make a variable contain multiple values - pyzyx3qwerty - Apr-30-2020

(Apr-29-2020, 05:23 PM)astral_travel Wrote: i wrote something like this, i hope it is what you wanted:

numbers_list = [1, 3, 5, 7, 9]
choice = int(input('please choose a number:'))

if choice in numbers_list:
        print('you just won !')
        
else:
    print('you just lost amigo, try again !')

Yes, basically we have to use the in operator