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
#1
Lets say I want to create a little program that asks for a user input of 1 through 10.
If that input is 1,3,5,7,9 the user wins
if the that input is 2,4,6,8 the user loses

I cannot figure out how to make a variable that contains all those integers.

I started with this:

input_value = input("Enter value 1 through 10:")
input_value = int(input_value)
win_num = [1, 3, 5, 7, 9]

if input_value == win_num:
   print("you win")
else:
   print("you lose")
I get you lose no matter the value I enter.
Reply


Messages In This Thread
How to make a variable contain multiple values - by stevenjwilliams83 - Apr-28-2020, 07:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Assignment to make a multiple choice game blacklight 1 2,888 Aug-14-2020, 02:37 AM
Last Post: Larz60+
  Passing multiple values from template to template card51shor 0 2,277 Jun-18-2020, 06:44 PM
Last Post: card51shor
  5 Variable- Multiple Boolean Code cf25 1 3,059 Dec-17-2019, 03:54 PM
Last Post: ichabod801
  Extracting variable values from labels on csv file using Python Laura 1 3,082 Nov-12-2018, 06:54 PM
Last Post: ichabod801
  How to make a dynamic variable based on input loltylerdowney 3 5,152 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