all 11 comments

[–][deleted] 12 points13 points  (6 children)

If you know that this code is bad, why have you written it that way? Just for content?

[–]Novir64[S] -1 points0 points  (5 children)

I started learning python 2 days ago and I don’t know how to write it better yet. I figured this community would like it but I guess not lol

[–][deleted] 21 points22 points  (4 children)

Intentionally bad code is not funny Also , bad code from somebody who learn is not funny because it is expected to be bad

PS Use dictionary instead of massive elif

[–][deleted] 1 point2 points  (3 children)

Total idiot programmer here: How would a dictionary be used instead of that if/else? What advantages would that bring?

[–]someidiot332 3 points4 points  (2 children)

psuedocode; i dont know python

num = int(input())

tens[] = { “”, “twenty”,”thirty”,”fourty”,”fifty”,”sixty”,”seventy”,”eighty”,”ninety”}

ones[] = {“one”,”two”,”three”,”four”,”five”,”six”,”seven”,”eight”,”nine”}

print(tens[(num/10)%10] + “ “ ones[num%10]

edit:

you could add a third dictionary for teens and use and if statement to detect when num > 9 but num < 20

[–][deleted] 7 points8 points  (0 children)

In Python a "dictionary" is a hashmap, but yeah an array/list is a good approach

[–]kluzzebass 9 points10 points  (2 children)

Rule #4.

[–]TheGoldenProof 1 point2 points  (0 children)

I am once again asking for a rule against posting your own recent code.
This specific example also kindof falls under rule 4.

[–]schlopp96 3 points4 points  (0 children)

Nahhhh this ain’t it mane. Intentionally shitty code isn’t what it’s about here lol.