I am working on a login system in python as practice and I keep on getting this error when I try to make a for loop..."Non-iterable value SignUp is used in an iterating context"
from SignUp import SignUp
userName = input("Enter a username: ")
userPass = input("Enter a password: ")
sign_up = SignUp(userName, userPass)
for user in SignUp:
newData = open("data.txt", "a")
newData.write(userName, userPass)
newData.close()
What does this error mean and how can I solve it?
You will need to make SignUp
class iterable. Depending on what SignUp
class is meant for, you will need to implement __iter__()
function inside your class. This link gives some examples of how to implement the same. for
loop internally uses the iterator protocol and hence we need to use an object that is iterable.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments