tries= 3
for i in range(3):
username=input("What is your username ")
if username =="student":
pwd=input("Whats your password ")
if pwd=="password":
print("welcome")
studentname=input("What is your full name? ")
studentage=input("What age ar you ")
f = open('data.txt', 'wb')
f.write("Student = " + str(studentname) + "\nAge = " + str(studentage))
f.close()
And when i enter the username it will say:
f.write("Student = " + str(studentname) + "\nAge = " + str(studentage))
UnboundLocalError: local variable 'studentname' referenced before assignment
Does anyone know what I'm doing wrong.