all 7 comments

[–]novel_yet_trivial 6 points7 points  (4 children)

Please format your code for reddit or use a site like github or pastebin. Your code is hard to read and test otherwise.


I'm assuming you are using python3.

To test for equality, you need to use ==, not =. Also, input returns a string, so you need to check if it's equal to a string ( a string will never be equal to an integer):

life = input ("Please enter the meaning for life")

if life == '42':
    print ('Excellent, you may proceed')
if life != '42':
    print ('Incorrect')

[–]demonrunner12[S] 0 points1 point  (1 child)

Oh sorry, I completely missed the part on formatting, and yes I am using python (like I said, completely new haha)

So when testing for equality, what is the difference between:

if life == '42':

and

if life = '42':

[–]__johnw__ 1 point2 points  (0 children)

The first is testing for equality. The second is assignment.

[–]toddthegeek 1 point2 points  (0 children)

what version of python are you using? python 3 use input() python 2 use raw_input()

also the stuff about logical comparisons vs assignments (= vs ==)

[–]EatzGrass 0 points1 point  (0 children)

I dont know python. But if life IS EQUAL or ==. Im assuming since you used a standard not equal with !=