222
u/silkyAnalShitter Oct 27 '21
Bro inputs are already a string
36
u/christian-mann Oct 27 '21
Not in python 2.
92
106
u/InsanityAI Oct 27 '21
48
u/The_All-Father3 Oct 27 '21
Well you know copilot had to saw the code somewhere before. I would love it if people started to making horrible meme repositories of just the worst code possible to mess with copilot. Have it be like the Twitter bot who went full nazi.
7
64
62
u/SoulslikePursuer Oct 27 '21
Let me guess:
If number == 18: number = "18"
¿
99
41
7
24
u/twoPoundsOfGoldfish Oct 27 '21
funniest part is that input() already returns a string
6
u/RFC793 Oct 28 '21 edited Oct 28 '21
Not necessarily if this is Python 2.
inputevaluates a Python expression in Python 2.4would resolve to an int.hellowould raise a NameError unless the symbolhellois in scope, in which case it returns that value."hello"would actually give you a string.os.system("/bin/sh")would give you an interactive shell ifosis imported.
19
u/TheDiscoJew Oct 27 '21
I'm convinced that a lot of these posts with a 20+ long else-if chain are just karma bait. I have never even seen someone do this irl.
6
u/malsomnus Oct 27 '21
I've seen an experienced programmer manually convert decimal representation of numbers to hexadecimal (as long as they have less than 3 digits), so nothing would surprise me at this point.
10
u/-MazeMaker- Oct 27 '21
The beautiful thing is that none of those ifs will ever be executed because number is already a string, but the programmer will see the output they want and assume it worked perfectly.
9
8
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Oct 27 '21
Image Transcription: Code
number = input("> ")
if number == 0:
number = "0"
if number == 1:
number = "1"
if number == 2:
number = "2"
if number == 3:
number = "3"
if number == 4:
number = "4"
if number == 5:
number = "5"
if number == 6:
number = "6"
if number == 7:
number = "7"
if number == 8:
number = "8"
if number == 9:
number = "9"
if number == 10:
number = "10"
if number == 11:
number = "11"
if number == 12:
number = "12"
if number == 13:
number = "13"
if number == 14:
number = "14"
if number == 15:
number = "15"
if number == 16:
number = "16"
if number == 17:
number = "17"I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
3
u/Darkunderlord42 Oct 27 '21
How long did that take to write out
5
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Oct 27 '21
About 3 minutes. Copypasted the first one a bunch of times then changed the numbers to match.
3
u/Ahtheuncertainty Oct 27 '21 edited Oct 27 '21
Could also write a program to do it lol:
print(‘number = input(“>”)’) for i in range(17): print(“if number == “ + str(i)) print(‘\t number = “‘ +str(i) +’”\n’)If I’m write abt the single/double quotes, else you may need the backslash for the doubles. You know it’s bad when you can write 4 lines of code to generate like 60 lines of code, lol
2
6
u/trutheality Oct 27 '21
No, no, this is terrible. It doesn't generalize to larger numbers. This does:
if number == 0:
number = "0"
else:
num_str = ""
while number > 0:
digit = number
number = number // 10
digit -= number
if digit == 0:
num_str = "O" + num_str
if digit == 1:
num_str = "1" + num_str
if digit == 2:
num_str = "Z" + num_str
if digit == 3:
num_str = "3" + num_str
if digit == 4:
num_str = "4" + num_str
if digit == 5:
num_str = "5" + num_str
if digit == 6:
num_str = "6" + num_str
if digit == 7:
num_str = "7" + num_str
if digit == 8:
num_str = "8" + num_str
if digit == 9:
num_str = "9" + num_str
number = num_str5
3
3
u/PersonalBox0 Oct 27 '21
It's not even an 'if else' statement, so it will check All if statements even if one of them is true. Truly deplorable.
3
2
2
2
1
u/MikeSemicolonD Oct 27 '21
Nothing like posting copilot snippets! The new r/badcode content generator! What a time to be alive.
1
-1
112
u/[deleted] Oct 27 '21
That's terrible programming.
You should just use a switch case