Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If , else, case?

Hallo!

Is there a function to help me out to test a condition without a 'cascade' of 'else(s)'? Like a "case"? I'm trying hard to find out a solution using the build-in help/manual and could not find a "case" statement. Thank you in advance.

r = randint(1,3)
if r == 1:
            print 'One.'
        if r == 2:
            print 'Two.'
        if r == 3:
            print 'Three.'

If , else, case?

Hallo!

Is there a function to help me out to test a condition without a 'cascade' of 'else(s)'? Like a "case"? I'm trying hard to find out a solution using the build-in help/manual and could not find a "case" statement. Thank you in advance.

r = randint(1,3)
if r == 1:
         print 'One.'
 if r == 2:
         print 'Two.'
 if r == 3:
         print 'Three.'