Home > Blockchain >  Errors on if an elif statements
Errors on if an elif statements

Time:12-13

I am a beginner at Python.

I am getting syntax errors on elif and If statements.

if "dc"=="dc":

elif "b"== "b":

CodePudding user response:

you should put some instructions within the block of the if and of course the elif

if something == 'my something':
    # Do something. - write your code here - what you want to do in case of something is actually equal to 'my something'
    # to just allow python compile you can reference the keyword
    pass
elif something == 'something else':
    pass
...
...

for next time, please provide the error python throws at you. python exceptions (at least on 3.9 ) provides excellent error exceptions that we actually can understand pretty fast.

CodePudding user response:

The same can be written in single line:

value = true-expr if condition else false-expr

if condition returns True then true-expr is assigned to value object

if condition returns False then false-expr is assigned to value object

  • Related