r/badcode • • Aug 27 '21

python Is this code bad or sugoi?

Post image
1.0k Upvotes

154 comments sorted by

View all comments

0

u/[deleted] Aug 27 '21

[deleted]

173

u/joonatoona Aug 27 '21
name = input("Please enter your name: ")
emoticon = "(°▽°)/ 🙇"
print("Hello {}! {}".format(name,emoticon))
def addNumbers(number1, number2):
    true = True
    if number1 or number2 < 0:
        return not true
    else:
        sum = number 1 + number2
    return sum
        
print("sum =", addNumbers(6, 9))

rain(?) = False
counter = 1
if not not not rain:
    while counter < 11:
        print(str(counter) + ". 😂😂")
        counter = counter + 1

God trying to format that on mobile sucked, and I probably got some of that wrong anyways.

75

u/[deleted] Aug 28 '21

if not not not? WTF is with the triple negative?

40

u/ycohui Aug 28 '21

that was the original code had triple not....

33

u/[deleted] Aug 28 '21

Yes, but why?

7

u/lkmnoppo Aug 28 '21

You can use double negation to convert from truthy-value to boolean, maybe the programmer wanted to do something like that. But you usually do double negation, not triple. Triple negation should have the same effect as single negation also on truthy values.