+ 1

Please help with input output!

I want my program to answer me according to the input. For example: saleTax = 7 if user input FL saleTax = 6 if user input TX

21st Jan 2017, 3:33 PM
Oleg
Oleg - avatar
7 Answers
+ 5
I would do as following: saleTax = input() if saleTax == "FL" saleTax = 7 else saleTax == "TX" saleTax = 6 I hope this helped.
21st Jan 2017, 3:55 PM
Seighin V.H.
Seighin V.H. - avatar
+ 2
I found a mistake: there should be a double dotts symbol ":", so code have to looks like this: x = input() if x == "FL": print("Florida") if x == "TX": print("Texas")
21st Jan 2017, 4:46 PM
Oleg
Oleg - avatar
0
it's giving me a syntax error with your code
21st Jan 2017, 4:35 PM
Oleg
Oleg - avatar
0
Yeah you're right. I always forget to put them there. Well, have fun finishing your project and Good luck.
21st Jan 2017, 4:51 PM
Seighin V.H.
Seighin V.H. - avatar
0
s=input () if s is FL print("saleTax=7") elif s is XL print("saleTax=6")
7th Feb 2017, 3:52 PM
Avnit Sharma
Avnit Sharma - avatar
- 1
Thank you for fast response! what if I need a text as an output? For example state = input() if state == "FL" state = "Florida" else state = "TX" state = "Texas" is it correct?
21st Jan 2017, 4:13 PM
Oleg
Oleg - avatar
- 1
If you want text dont forget the print commando. like this then: state = input() if state == "FL" print ("Florida") else state = "TX" print ("Texas") I hope this is what you mean.
21st Jan 2017, 4:23 PM
Seighin V.H.
Seighin V.H. - avatar