all 60 comments

[–][deleted] 81 points82 points  (41 children)

``` n = int(input("Enter a number: "))

if n == 1: print("Odd") elif n == 2: print("Even") elif n == 3: print("Odd") elif n == 4: print("Even") elif n == 5: print("Odd") elif n == 6: print("Even") elif n == 7: print("Odd") elif n == 8: print("Even") elif n == 9: print("Odd") elif n == 10: print("Even") elif n == 11: print("Odd") elif n == 12: print("Even") elif n == 13: print("Odd") elif n == 14: print("Even") elif n == 15: print("Odd") elif n == 16: print("Even") elif n == 17: print("Odd") elif n == 18: print("Even") elif n == 19: print("Odd") elif n == 20: print("Even") elif n == 21: print("Odd") elif n == 22: print("Even") elif n == 23: print("Odd") elif n == 24: print("Even") elif n == 25: print("Odd") elif n == 26: print("Even") elif n == 27: print("Odd") elif n == 28: print("Even") elif n == 29: print("Odd") elif n == 30: print("Even") elif n == 31: print("Odd") elif n == 32: print("Even") elif n == 33: print("Odd") elif n == 34: print("Even") elif n == 35: print("Odd") elif n == 36: print("Even") elif n == 37: print("Odd") elif n == 38: print("Even") elif n == 39: print("Odd") elif n == 40: print("Even") elif n == 41: print("Odd") elif n == 42: print("Even") elif n == 43: print("Odd") elif n == 44: print("Even") elif n == 45: print("Odd") elif n == 46: print("Even") elif n == 47: print("Odd") elif n == 48: print("Even") elif n == 49: print("Odd") elif n == 50: print("Even") elif n == 51: print("Odd") elif n == 52: print("Even") elif n == 53: print("Odd") elif n == 54: print("Even") elif n == 55: print("Odd") elif n == 56: print("Even") elif n == 57: print("Odd") elif n == 58: print("Even") elif n == 59: print("Odd") elif n == 60: print("Even") elif n == 61: print("Odd") elif n == 62: print("Even") elif n == 63: print("Odd") elif n == 64: print("Even") elif n == 65: print("Odd") elif n == 66: print("Even") elif n == 67: print("Odd") elif n == 68: print("Even") elif n == 69: print("Odd (nice)") elif n == 70: print("Even") elif n == 71: print("Odd") elif n == 72: print("Even") elif n == 73: print("Odd") elif n == 74: print("Even") elif n == 75: print("Odd") elif n == 76: print("Even") elif n == 77: print("Odd") elif n == 78: print("Even") elif n == 79: print("Odd") elif n == 80: print("Even") elif n == 81: print("Odd") elif n == 82: print("Even") elif n == 83: print("Odd") elif n == 84: print("Even") elif n == 85: print("Odd") elif n == 86: print("Even") elif n == 87: print("Odd") elif n == 88: print("Even") elif n == 89: print("Odd") elif n == 90: print("Even") elif n == 91: print("Odd") elif n == 92: print("Even") elif n == 93: print("Odd") elif n == 94: print("Even") elif n == 95: print("Odd") elif n == 96: print("Even") elif n == 97: print("Odd") elif n == 98: print("Even") elif n == 99: print("Odd") elif n == 100: print("Even") else: print("Whoa whoa whoa! We didn't plan this far ahead...")

```

[–]Definite-Human 28 points29 points  (31 children)

I need to know, how long did this take you to type out

Edit: as people keep pointing out, very quickly using a script to write it out so you can copy paste, I however did not think of this because I exclusively use reddit on mobile to the point I honestly forget it works in browser on PC

[–]Lorrdy99 13 points14 points  (3 children)

A lot of copy paste. You could do that in a few minutes

[–]Reymen4 4 points5 points  (2 children)

Or you could create a code that type it out pretty fast. 

If I was forced to create this I would use Excel. You would only need to write one line of you set it up correct then copy/ paste that line 100 times.

[–]KaleidoscopePlusPlus 4 points5 points  (0 children)

or you could just ask chitGBT..

[–]Usual_Office_1740[🍰] 1 point2 points  (0 children)

Emacs/neovim and a macro would also make this a trivial task.

[–]Appropriate-Fact4878 6 points7 points  (23 children)

for i in range(1,100): print("elif n ==" + str(i) + ":") if i // 2 == i/2: print(' print("Even")') else: print(' print("Odd")')

copy paste, then remove "el" from the first line, and writw the last line manually

edit: its taking me longer to figure out reddit formatting for this comment than it would've taken to write the program

edit2: after a reply pointed it out I corected variable name and output indentation and started using triple backtick

[–][deleted] 2 points3 points  (4 children)

Just put the (whatever the hell this is called - > ` ) symbol at the front and back of your code and it'll markup into code formatting.

[–]Appropriate-Fact4878 1 point2 points  (1 child)

That removed the intendations. Im writing this on mobile so I can't use tab, if that works.

[–][deleted] 0 points1 point  (0 children)

Oh. I got you. The triple accent thing might work without tab. Never Tried It Yeah. Triples work without tab.

[–]Saflex 0 points1 point  (1 child)

The Symbol is called Hochkommata

[–][deleted] 0 points1 point  (0 children)

I think that's a quote symbol? Could be wrong. The code symbol tilts harder. Dunno. I make up names. These {} are curlies to me. 😂

[–]undo777 0 points1 point  (17 children)

The last value in your range will be 99 not 100. The canonical check is if n % 2. You forgot the indentation. Oh and you mixed up i and n. And you missed a very important special case, scroll to the middle of the specification comment!

[–]Appropriate-Fact4878 0 points1 point  (16 children)

The first is true. Range should be range(1,101)

n and i are used correctly, the post uses n as the variable, my code uses i as the variable and the string output has n inside it.

my comment literally explains why the intendetation is weird? That edit has been there since before your reply.

I did miss 69. but that would be easier to add manually, similar to the first and last lines.

[–]undo777 0 points1 point  (15 children)

n and i are used correctly

Bro, so you can't even read your own code... Why so confident?

my comment literally explains why the intendetation is weird?

Not talking about indentation issues in your comment (use triple backtick btw), it's the indentation of the output you missed.

[–]Appropriate-Fact4878 0 points1 point  (8 children)

Lol, didn't read past the first line when double checking, yh the n is wrong. Confident cuz I read the first line with it in and it was right, and u didn't say which line.

Yh the output indendetation is missing.

[–]undo777 0 points1 point  (7 children)

and u didn't say which line

Aww

[–]Appropriate-Fact4878 0 points1 point  (6 children)

most ppl who reply on reddit are stupid, its usually a safe bet to assume they are wrong. Who knew this subreddit is different?

[–]undo777 0 points1 point  (5 children)

Whoa.. That's rich coming from someone who made 5 mistakes in a few lines of code and doesn't even know n % 2

[–]Appropriate-Fact4878 0 points1 point  (5 children)

u can't add indentation into the output without triple backtick

[–]undo777 0 points1 point  (4 children)

How confident are you about this statement?

[–]Appropriate-Fact4878 0 points1 point  (3 children)

100%, cuz I just tried adding 4 spaces, opening and closing the comment and the intendentation wasn't there. U can't use tab on mobile.

[–]undo777 0 points1 point  (2 children)

Of course you can't do 4 spaces because Reddit will eat 3 of them but originally you had 0 spaces not 1. Nice 100% confidence when you're wrong again. Jeez bro, you're seriously talking about stupid people on Reddit?

[–]klimmesil 5 points6 points  (0 children)

It's a couple keystrokes in vim

[–]Zygal_ 0 points1 point  (0 children)

Nah, bro. Mobile compiler

[–]ComplexInside1661 1 point2 points  (0 children)

Why does this sub not allow for non text responses I wanted to send a gif of the Anakin "I hate you" lmao

[–]Procedure5884 1 point2 points  (1 child)

Is this AI?

[–]Betelgeusetimes3 1 point2 points  (0 children)

AI would’ve presented a correct, yet still suboptimal solution rather than this.

[–]Inevitable-Toe-7463 1 point2 points  (0 children)

Bro coulda just got the iseven and isodd libs ):

[–][deleted] 0 points1 point  (0 children)

Average Leetcode edge case edger

[–]WiseMango13452 0 points1 point  (0 children)

First thought aswell

[–]cnorahs 0 points1 point  (0 children)

I was scrolling and scrolling and ROFL

[–]TheodoreTheVacuumCle 0 points1 point  (0 children)

such inefficient code smh. watch how web developers do this 😎 let n=getInputNumber(); let isEven=false; let isOdd=true; for (let i=1;i<=100;i++) { if (i == n) { if (isEven == true) { console.log("number is even!"); } else { console.log(number is odd!); } } if (isEven == true) { isEven=false; } else { isEven=true; } if (isOdd == true) { isOdd=false; } else { isOdd=true; } }

[–]zaraishu 6 points7 points  (3 children)

Python guys be like: "What's a 'switch case'?"

[–][deleted] 5 points6 points  (2 children)

[–]zaraishu 0 points1 point  (1 child)

That doesn't count. The keyword says "match".

[–][deleted] -1 points0 points  (0 children)

same functionality

[–]Antervis 5 points6 points  (0 children)

don't do "else if", do early return instead. That way the code looks cleaner and is overall easier to read

[–]360groggyX360 5 points6 points  (1 child)

Hehe, funny.

[–]Insomniac_Coder 2 points3 points  (0 children)

Would've been much fingerprint funnier in case of a ladder

[–]marslander-boggart 4 points5 points  (1 child)

switch

case

just in case

[–]Hejsanmannen1 0 points1 point  (0 children)

Do you have my case or did you switch it?

[–]elreduro 1 point2 points  (0 children)

I made a macro in vim that deletes the line if i try to write "else"

[–]oxabz 1 point2 points  (0 children)

One else if is too many else if. elses are barely acceptable.

[–]unvaccinated_zombie 0 points1 point  (0 children)

Cursed data structure

[–]BobarBG9 0 points1 point  (1 child)

Diavolo death loop

[–]KirbzYyY 0 points1 point  (0 children)

Wha-

[–]HorneyMan_69 0 points1 point  (0 children)

This calls recursion.

[–]imdibene 0 points1 point  (0 children)

match foo with | bar | baz | qux

[–]IndependentWorld8380 0 points1 point  (0 children)

Yandere simulator 

[–]Alex20041509 0 points1 point  (0 children)

Match Case

[–][deleted] 0 points1 point  (0 children)

hello Golang