Python conditionals: Difference between revisions

From wikinotes
 
No edit summary
 
Line 19: Line 19:
     print('success')
     print('success')
</source>
</source>
= match =
<blockquote>
<syntaxhighlight lang="python">
match name:
    case "will":
        print("its me")
    case "maize":
        print("its the cat")
</syntaxhighlight>
</blockquote><!-- match -->

Latest revision as of 02:01, 14 February 2024

if statement

if var == 'no' :
   print "something"
elif var == 'yes' :
   print "something else"
else:
   print "something else entirely"


You may find the all keyword useful:

if all([
    a == 1,
    b == 2,
    c == 3,
]):
    print('success')

match

match name:
    case "will":
        print("its me")
    case "maize":
        print("its the cat")