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
+
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.

#11
SOURVLRT
0
Frags
+
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

#12
ALoKi007
0
Frags
+
SOURVLRT [#11]

match case looks cleaner though

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

#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
+
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 :(

#15
SOURVLRT
0
Frags
+
ALoKi007 [#12]

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

im a java programmer, i dont know shit about python

#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

#18
ALoKi007
0
Frags
+
SOURVLRT [#15]

im a java programmer, i dont know shit about python

I want to learn advanced JAVA 😭

#19
Prancer
0
Frags
+
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)

#20
Prancer
0
Frags
+
SOURVLRT [#14]

but 18 - 50, gives only ashes left :(

works as intended

#21
Prancer
0
Frags
+
LingWang [#17]

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

50 isnt young

#22
widepeepofrosty
-1
Frags
+

This is shit, quit now

#23
Prancer
0
Frags
+
widepeepofrosty [#22]

This is shit, quit now

most supportive vlr user

#24
widepeepofrosty
0
Frags
+
Prancer [#23]

most supportive vlr user

Thank you ☺️

#25
SnooTangerines
0
Frags
+
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.

#26
EntryKJ
0
Frags
+
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

  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

#27
JMZxp
0
Frags
+
LingWang [#17]

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

Bro got the Drake codebase

#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
+
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

#32
bladaaa
0
Frags
+

you can try using input()

#33
omegaishere
0
Frags
+
zappp [#31]

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

thnx

  • 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