is this good?
age = 65
if age <18:
print("Minor LMAO😹")
elif 50<= age <60:
print("Ancient AAAH")
else:
print("Only ashes left💀")
SOURVLRT [#9]age = 65
match age:
case if age < 18:
print("Minor LMAO😹")
case if 50 <= age < 60:
print("Ancient AAAH")
case _:
print("Only ashes left💀")here you go bud, cleaner code
Naah for such small problem OP's solution is okay. No need for match-case if there aren't any complex conditions.
ALoKi007 [#10]Naah for such small problem OP's solution is okay. No need for match-case if there aren't any complex conditions.
match case looks cleaner though
SOURVLRT [#11]match case looks cleaner though
Yes that's correct. Though python is more about being optimal!
LingWang [#13]thank you everyone and yes my code does work
https://imgur.com/a/sFfGD1u
https://imgur.com/OO5wpSS
but 18 - 50, gives only ashes left :(
ALoKi007 [#12]Yes that's correct. Though python is more about being optimal!
im a java programmer, i dont know shit about python
SOURVLRT [#15]im a java programmer, i dont know shit about python
i thinks its a type of snake? (i dont know anything about code)
SOURVLRT [#11]match case looks cleaner though
No it doesn't python code should be written the pythonic way which for such problems, match case just doesn't look good. Also, it is really redundant and only increases the headaches of people looking at the code.
SOURVLRT [#9]age = 65
match age:
case if age < 18:
print("Minor LMAO😹")
case if 50 <= age < 60:
print("Ancient AAAH")
case _:
print("Only ashes left💀")here you go bud, cleaner code
if you try writing this correctly with match-case, you will end up writing if statements within the cases, and at that point you can't call it cleaner
omegaishere [#30]any programmers out here wanna tell me how to start out with java? any specific courses to learn from?
i got some experience in python and c# but only basics for uni
Udemy course: Learn JAVA Programming - Beginner to Master by Abdul Bari