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
  Input function oldschool 1 678 Sep-14-2024, 01:02 PM
Last Post: deanhystad
  difference between forms of input a list to function akbarza 6 2,308 Feb-21-2024, 08:02 PM
Last Post: bterwijn
  'answers 2' is not defined on line 27 0814uu 4 1,707 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 2,290 Dec-25-2022, 03:00 PM
Last Post: askfriends
  Showing an empty chart, then input data via function kgall89 0 1,449 Jun-02-2022, 01:53 AM
Last Post: kgall89
  input function question barryjo 12 4,503 Jan-18-2022, 12:11 AM
Last Post: barryjo
  function with 'self' input parameter errors out with and without 'self' called dford 12 7,240 Jan-15-2022, 06:07 PM
Last Post: deanhystad
  Problem with input after function luilong 10 5,976 Dec-04-2021, 12:16 AM
Last Post: luilong
  Exit function from nested function based on user input Turtle 5 4,257 Oct-10-2021, 12:55 AM
Last Post: Turtle
Star I'm getting syntax error while using input function in def. yecktmpmbyrv 1 2,692 Oct-06-2021, 09:39 AM
Last Post: menator01

Forum Jump:

User Panel Messages

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