0

How can I exclude an input(plz see disc.)

Hi. So I was trying to write a code and I noticed a problem.. It was something like this. X = input("") Y = input("") Z = input("") If x == a: Print("y" + "z") elif x == b : Print ("y") So if I take x==b it will show an error.. Is there some way to exclude z when not needed. If there is please let me know Thanks😃

6th Sep 2019, 1:31 PM
Manas
Manas - avatar
1 Antwort
+ 1
Because you are asking for all three inputs first, the expectation is you will input something for each of them. You could make your inputs conditional, for example: This is pseudocode not real python code: x = input("") if x == a: y = input("") z = input("") print("y" + "z") elif x == b: y = input("") print(y) EDIT don't forget if you're testing this in CodePlayground you need to put each input on a separate line, e.g: a hello world or: b hello
6th Sep 2019, 1:44 PM
Rincewind
Rincewind - avatar