0

How do i check for input?

How do i make my program check for input? As in "if there is input: do something"

26th Jul 2022, 10:57 AM
Unexpected Explosions
Unexpected Explosions - avatar
5 Réponses
0
Hi, Unexpected Explosions ! If there is the possibility to use multiple inputs you looking for, and you don’t know the number of inputs from the beginning, you can take a look at this code: https://code.sololearn.com/cbPe32KfwQhF/?ref=app Just ask if you have any questions.
26th Jul 2022, 11:30 AM
Per Bratthammar
Per Bratthammar - avatar
+ 6
Unexpected Explosions , just as Lisa mentioned: name = input() if name == "Tom": do this... elif name == "Ann": do this... elif name == "": do this.... else: do this.... instead of strings you can also handle numerical inputs.
26th Jul 2022, 11:17 AM
Lothar
Lothar - avatar
+ 5
You can use the input() as described in lesson 16 of Python for Beginners. If the input is empty (""), you can use default values
26th Jul 2022, 11:00 AM
Lisa
Lisa - avatar
+ 3
n = input() if n: print('There's an input')
26th Jul 2022, 11:24 AM
Korkunç el Gato
Korkunç el Gato - avatar
0
Lisa, That's not exactly what i need. This lesson explains how to use the "input" function in general, not how to pair it with the "if" operator
26th Jul 2022, 11:08 AM
Unexpected Explosions
Unexpected Explosions - avatar