+ 2

Pycharm not allowing defining variables under if statements.

choice_1 = input("\n Choose a letter. \n A: AAA \n B: BBB \n") if choice_1 == 'A': print("XYZ") choice_2 = input("A: ABC \n B: DEF \n C: GHI \n") if choice_2 == 'A': print("XYZ") elif choice_2 == 'B': print("UVW") elif choice_2 == 'C': print("RST") else: print("That is not a choice") Pycharm tells me that variable choice_2 not defined, but this works in IDLE and Sololearn playground. thanks everyone!

10th Nov 2017, 9:17 PM
Nitay Eshed
Nitay Eshed - avatar
5 Answers
0
try printf
11th Nov 2017, 2:39 AM
DĘ°Ę”ng Đįŗ·ng
DĘ°Ę”ng Đįŗ·ng - avatar
0
For indentation, use tab
11th Nov 2017, 4:00 AM
privrax.
privrax. - avatar
0
So what would be the correct way to write it?
12th Nov 2017, 1:04 AM
Nitay Eshed
Nitay Eshed - avatar
0
Hmm... depends. When you sort out this problem, will this be the final product?
12th Nov 2017, 1:45 AM
privrax.
privrax. - avatar