Bottom Page

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!")
Yoriz wrote Jul-19-2019, 01:41 PM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.
I also added in the indentation that was missing.
Quote
#2
Welcome to the forum, did you have a question ?
Quote
#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".
Quote
#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.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Getting an error while using input function dcsethia 5 154 May-11-2020, 04:59 PM
Last Post: buran
  Input() function not working in VS Code darpInd 7 417 Feb-17-2020, 03:28 PM
Last Post: snippsat
  Using input function in a Class wew044 2 255 Feb-06-2020, 03:08 AM
Last Post: wew044
  what would you call the input for the parameter(s) of a function you have defined? rix 3 277 Dec-16-2019, 12:04 AM
Last Post: rix
  Mathematical function input Tiiill 2 335 Sep-10-2019, 09:25 PM
Last Post: nilamo
  Function and Input binary44380 3 379 Aug-07-2019, 01:41 PM
Last Post: ThomasL
  Getting type from input() function in Python 3.0 leodavinci1990 7 660 Jul-29-2019, 08:28 PM
Last Post: avorane
  5 python columns, row-wise as input to a function dervast 1 416 Jul-17-2019, 08:53 PM
Last Post: Larz60+
  Input as function parameter dan789 1 465 Mar-08-2019, 05:19 PM
Last Post: Larz60+
  how do I take an input and put it in a function? mitmit293 4 523 Jan-30-2019, 04:51 PM
Last Post: perfringo

Forum Jump:


Users browsing this thread: 1 Guest(s)