31
loading...
This website collects cookies to deliver better user experience
foo
, bar
, and math examples is the bane of your existence, keep reading. Expect examples with sweaters and dogs.dog_name = input("What is your dog's name?")
dog_wants_to_play = True # they always want to play!
match dog_wants_to_play:
case True:
print("Go get it", dog_name)
case False:
print("Okay", dog_name, "maybe we'll play later")
dog_name = input("What is your dog's name?")
dog_wants_to_play = True # they still always want to play!
if dog_wants_to_play:
print("Go get it", dog_name)
else:
print("Okay", dog_name, "maybe we'll play later")
if sweater_sleeves == 8:
print("give to spider, squid, or octopus")
elif sweater_sleeves == 6:
print("give to butterfly, bumble bee, Octocat™")
elif sweater_sleeves == 4 or sweater_sleeves > 2:
print("give to 3 or 4 legged dog")
elif sweater_sleeves == 2 or sweater_sleeves == 1:
print("give sweater to human with 1 or 2 arms")
elif sweater_sleeves == 0:
print("give sweater to to your snake friend")
else:
print("sweater is broken, make another one")
sweater_sleeves = int(input("How many sleeves does the sweater have?"))
match sweater_sleeves:
case 8:
print("give to spider, squid, or octopus")
case 6:
print("give to butterfly, bumble bee, Octocat™")
case 3 | 4:
print("give to 3 or 4 legged dog")
case 2 | 1:
print("give sweater to human with 1 or 2 arms")
case 0:
print("give sweater to to your snake friend")
case > 8: # NOTE: unsure on the accuracy of this line's syntax
print("sweater is broken, make another one")
case _:
print("You made a sweater")
_
. This will always be True and it considered irrefutable. You may only have one irrefutable case and it has to be the at the end.