Python Forum

Full Version: Using answers from an input function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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!")
Welcome to the forum, did you have a question ?
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".
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.