why does this line of code not working | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why does this line of code not working

name = input("what is your name") if name = (Colby) print("hello brother")

25th Jun 2016, 2:57 AM
Barry Yee
Barry Yee - avatar
3 Answers
+ 3
comparison operator for equality is ==, or === if you also need to compare types. = is an assignment operator for assigning data on the right to the variable on the left. your code should be the following: name = input("what is your name?") if name == "Colby": print("hello brother")
25th Jun 2016, 5:22 AM
Colin Butler
Colin Butler - avatar
0
you should write: " if name = ("Colby"): "
25th Jun 2016, 3:46 AM
toto
0
= is the assignment operator. you gotta use 'is' for comparison as in: if name is ('Colby'): print(' whaad up col dawg?!')
25th Jun 2016, 10:08 AM
karan wadhwa
karan wadhwa - avatar