Forget about if-elif-else with Match-Case construction Python

Опубликовано: 02 Октябрь 2024
на канале: Python 5
2,102
97

Python tips and tricks
#shorts #python #programming #coding

a = int(input("Enter some value: "))
if a == 1:
print("Its one")
elif a == 2:
print("Its two")
else:
print("Another value:", a)

match a:
case 1:
print("its one")
case 2:
print("its two")
case default:
print("another value", a)