2

Just started coding python

posted in Off Topic
Comments:
Threaded Linear
#1
LingWang

is this good?

age = 65
if age <18:
print("Minor LMAO😹")
elif 50<= age <60:
print("Ancient AAAH")
else:
print("Only ashes left💀")

#2
Zaphkiel
1
Frags
+

Good job

#3
nobody___100
2
Frags
+

give this to dr disrespect it will be helpful

#4
ninjaturtle
0
Frags
+

Ironically I did this while starting out in Python as well lmao

#5
cloudberry
2
Frags
+

If you're 34 it'll print "Only ashes left💀", but the choice itself is fine

#6
greedeetv
0
Frags
+

if ur age between 18 and 50 it gonna go to the else case

#7
cobalt21312
0
Frags
+

as said before, u need a case for between 18 and 50

#8
ALoKi007
0
Frags
+

The code will not work. Indentation error exists...

#9
SOURVLRT
0
Frags
+

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

#10
ALoKi007
0
Frags
+

Naah for such small problem OP's solution is okay. No need for match-case if there aren't any complex conditions.

#11
SOURVLRT
0
Frags
+

match case looks cleaner though

#12
ALoKi007
0
Frags
+

Yes that's correct. Though python is more about being optimal!

#15
SOURVLRT
0
Frags
+

im a java programmer, i dont know shit about python

#18
ALoKi007
0
Frags
+

I want to learn advanced JAVA 😭

#19
Prancer
0
Frags
+

i thinks its a type of snake? (i dont know anything about code)

#25
SnooTangerines
0
Frags
+

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.

#26
EntryKJ
0
Frags
+
  1. wrong syntax, try running it
  2. it's not cleaner for this scenario

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

#13
LingWang
0
Frags
+

thank you everyone and yes my code does work
https://imgur.com/a/sFfGD1u
https://imgur.com/OO5wpSS

#14
SOURVLRT
0
Frags
+

but 18 - 50, gives only ashes left :(

#20
Prancer
0
Frags
+

works as intended

#16
LingWang
0
Frags
+

how to fix because the code you paste didn't have the indents. me confuse bro

#17
LingWang
0
Frags
+

fixed
https://imgur.com/r2qIQTG
https://imgur.com/eKgUmju

#21
Prancer
0
Frags
+

50 isnt young

#27
JMZxp
0
Frags
+

Bro got the Drake codebase

#22
widepeepofrosty
-1
Frags
+

This is shit, quit now

#23
Prancer
0
Frags
+

most supportive vlr user

#24
widepeepofrosty
0
Frags
+

Thank you ☺️

#28
luckypleb
0
Frags
+

this is trash u should be ashamed of yourself

#29
Cu55Ku55_______
0
Frags
+

Not bad for a first timer

#30
omegaishere
0
Frags
+

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

#31
zappp
0
Frags
+

Udemy course: Learn JAVA Programming - Beginner to Master by Abdul Bari

#33
omegaishere
0
Frags
+

thnx

#32
bladaaa
0
Frags
+

you can try using input()

  • Preview
  • Edit
› check that that your post follows the forum rules and guidelines or get formatting help
Sign up or log in to post a comment