-1

shouldn't this code theoretically work, i am new to python coding and i am having a hard time working with this, I'm just doing some practices to get the hang of it. update thank you, i didnt pay attention, im going to leave it like this so if someone else missed a typo like that, they can see they were not the only one.

answer = input()
 
  if answer = 6:
    print("you are correct")
 else:
    print("try again")
  • 4
    do you want to do `answer == 6` (with double equals) for comparison? – Moinuddin Quadri Jan 14 '21 at 19:48
  • [How can I read inputs as numbers?](https://stackoverflow.com/questions/20449427/how-can-i-read-inputs-as-numbers) – Sayse Jan 14 '21 at 19:49
  • In programming you get 5 main different types (I know this is more complex and untrue but for simplicity). Basically you're telling the computer if a variable you're saving (in your case 'answer') is basically going to be a string (str) which can be numbers and characters, or an Integer (purely numbers), or a float (decimal), or a Boolean (Bool), or a character (Char). Look up booleans (True and False), (ASCII, UTF8 both used for strings and chars), these things may become a bit clearer. (Arseniy is correct) – whaledotpy Jan 14 '21 at 20:10

1 Answers1

2
  1. The indentation is the part of syntax in python. You have an extra space before "if" statement

  2. use "==" instead of "=" for comparisons

  3. String to int

TLDR:

answer = int(input())
 
if answer == 6:
   print("you are correct")
else:
   print("try again")
Arseniy
  • 680
  • 5
  • 10