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
  difference between forms of input a list to function akbarza 6 928 Feb-21-2024, 08:02 PM
Last Post: bterwijn
  'answers 2' is not defined on line 27 0814uu 4 671 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 1,033 Dec-25-2022, 03:00 PM
Last Post: askfriends
  Showing an empty chart, then input data via function kgall89 0 943 Jun-02-2022, 01:53 AM
Last Post: kgall89
  input function question barryjo 12 2,636 Jan-18-2022, 12:11 AM
Last Post: barryjo
  function with 'self' input parameter errors out with and without 'self' called dford 12 3,009 Jan-15-2022, 06:07 PM
Last Post: deanhystad
  Problem with input after function luilong 10 4,021 Dec-04-2021, 12:16 AM
Last Post: luilong
  Exit function from nested function based on user input Turtle 5 2,858 Oct-10-2021, 12:55 AM
Last Post: Turtle
Star I'm getting syntax error while using input function in def. yecktmpmbyrv 1 1,932 Oct-06-2021, 09:39 AM
Last Post: menator01
  Division calcuation with answers to 1decimal place. sik 3 2,091 Jul-15-2021, 08:15 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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