Also, can I use any of these below?
if X == Y or Z:
if X == Y and Z == I:
if X == Y or Z == Y:
Thank you in advance
choice = input("Do you want to exit this programme (y/Y): ")
if choice == "y" or "Y":
print("Thank you for using this software. ")
elif choice == "n":
username = print("Please give a name: ")
password = print ("Please give a password: ")
if username == John and password == password:
print("The user is accepted.")
else:
print("The name you input was ", len(password), " ", "character long", "", ",", " ", "but that or the username was not correct.")
else:
print("Something went wrong")
or âusernameâ and âpasswordâ become variables x and y:
x = input ("Please input username: ")
y = input ("Please input password: ")
if x == John and y == password:
print("The user is accepted.")
The correct username to pass is âJohnâ and the correct password is actually âpasswordâ in this exercise.
Am I correct in that:
-a text variable can contain numbers,
-a text variable cannot contain text
-a, b, c, d, ⌠x, y, z can contain text and numbers?
That is much better than using x and y as the variables.
But this is wrong:
if username == John
That tries to find the variable John which does not exist. You need to use a string "John". Notice the quotation marks.
(Also, you canât just randomly indent lines of code. Python requires correct indentation. If you donât know the indentation rules, please ask.)
There is no such thing as âtext variablesâ in Python, and there is nothing special about variables x, y, z etc except that they are one letter and donât have a meaningful name.
Every variable in Python can hold anything you like: text, numbers, lists, sets, dicts, or any other sort of object you want. You can even lie if you want.
Yes, you should be using âinputâ to accept input. Check the spelling, though!
The second point is that John is a variable name, not a string. You forget the quotes: "John". And the same with âpasswordâ: password is a variable name, "password" is a string.