jeudi 3 décembre 2020

What is the difference between those two Python codes? [closed]

Sorry for that question but I'm new at Python.

while True:
a=input("Number:")
if (a=="q"):
        print("exiting...")
        break

This code is running.

while True:
a = (input("Number: ")
if (a == "q"):
    print("Exiting...")
    break  

This is not running on Python3. That is the console output:

if (a == "q"):
             ^

SyntaxError: invalid syntax`

Aucun commentaire:

Enregistrer un commentaire