Good day everyone, I need to print data using if-elif statement. I when I run this code like this, everything went well

if row['username'] == 'mutago':
        
        print " okay"
        sys.exit(0)
 else:
     print "wrong"

OKAY now i want to include elseif statement to print another data but it returns error. below is the error code

if row['username'] == 'mutago':
        
        print " okay"
        sys.exit(0)
elif row['password']=='muta55':
print "good"
 else:
     print "wrong"

i have tried also elseif but does not work

Recommended Answers

All 5 Replies

Your indention is completely off.

Here this will help you.

if row['username'] == 'mutango':
    if row['password'] == 'muta55':
        print "okay"
        sys.exit(0)
else:
   print "Wrong"

thanks. it working

fyi, there is no elseif in python...

The OP has it correct

I need to print data using if-elif statement
elif row=='muta55':

.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.