Python Forum
How to make a variable contain multiple values
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make a variable contain multiple values
#11
(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
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply


Messages In This Thread
RE: How to make a variable contain multiple values - by pyzyx3qwerty - Apr-30-2020, 07:22 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Assignment to make a multiple choice game blacklight 1 2,168 Aug-14-2020, 02:37 AM
Last Post: Larz60+
  Passing multiple values from template to template card51shor 0 1,735 Jun-18-2020, 06:44 PM
Last Post: card51shor
  5 Variable- Multiple Boolean Code cf25 1 2,368 Dec-17-2019, 03:54 PM
Last Post: ichabod801
  Extracting variable values from labels on csv file using Python Laura 1 2,218 Nov-12-2018, 06:54 PM
Last Post: ichabod801
  How to make a dynamic variable based on input loltylerdowney 3 3,807 Nov-30-2017, 09:49 PM
Last Post: loltylerdowney

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020