Python Forum
Using answers from an input function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using answers from an input function
#1
I've decided to teach myself programming and am new to the science. I started with a book on python and often try write code that's more complex than the examples provided in the book.

To get to the point here is an example from the book about the if and elif statements.
print("1. Red")
print("2. Orange")
print("3. Yellow")
print("4. Green")
print("5. Blue")
print("6. Purple")
Choice = int(input("Select your favorite color: "))
if (Choice == 1):
    print("You chose Red!")
elif (Choice == 2):
    print("You chose Orange!")
elif (Choice == 3):
    print("You chose Yellow!")
elif (Choice == 4):
    print("You chose Green!")
elif (Choice == 5):
    print("You chose Blue!")
elif (Choice == 6):
    print("You chose Purple!")
else:
    print("You made an invalid choice!")
Reply
#2
Welcome to the forum, did you have a question ?
Reply
#3
I did, but when I wanted to change the post because I accidentally posted it without finishing the question it said that "I couldn't make changes to a post that older than 10 mins".
Reply
#4
Just post your question in other post under,there is a restrictions to 10 mins for 0-4 posts users.
When have over 5 posts can edit up to 48 hours.
Permissions and Groups.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Two arguments in input function Alfredd 4 811 Nov-09-2025, 12:56 AM
Last Post: Pedroski55
  Using a For Loop to subtract numbers from an input function. Anunderling 9 2,819 Sep-22-2025, 08:56 PM
Last Post: deanhystad
  Input function oldschool 1 1,255 Sep-14-2024, 01:02 PM
Last Post: deanhystad
  difference between forms of input a list to function akbarza 6 3,499 Feb-21-2024, 08:02 PM
Last Post: bterwijn
  'answers 2' is not defined on line 27 0814uu 4 3,117 Sep-02-2023, 11:02 PM
Last Post: 0814uu
Information How to take url in telegram bot user input and put it as an argument in a function? askfriends 0 3,131 Dec-25-2022, 03:00 PM
Last Post: askfriends
  Showing an empty chart, then input data via function kgall89 0 1,902 Jun-02-2022, 01:53 AM
Last Post: kgall89
  input function question barryjo 12 5,872 Jan-18-2022, 12:11 AM
Last Post: barryjo
  function with 'self' input parameter errors out with and without 'self' called dford 12 12,323 Jan-15-2022, 06:07 PM
Last Post: deanhystad
  Problem with input after function luilong 10 7,449 Dec-04-2021, 12:16 AM
Last Post: luilong

Forum Jump:

User Panel Messages

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