So if you look at line 4 and 12 you see when i register everything the user puts in should show up in the txt file but i doesn't and if you look at line 38 it give's me an error it tells me that everything i have put in between the parentheses is not recognized.
from __future__ import with_statement
from asyncore import write
def reg(Ussername, Password, Age, Real_name, Last_name, Email):
global file
file = open ("User_details.txt","a")
file.write("\n" Ussername "," Password "," Age "," Real_name "," Last_name "," Email)
file.close
def login():
pass
def Access():
if option1 == "login":
input ("Ussername: ")
input ("Password: ")
input ("Age: ")
input ("Real name: ")
input ("Last name: ")
input ("Email: ")
login()
else:
print ("Enter all the info we will be asking you to register")
input ("Ussername: ")
input ("Password: ")
input ("Age: ")
input ("Real name: ")
input ("Last name: ")
input ("Email: ")
def begin():
global option1
print ("Hi my name is Steve would you like to register or login")
option1 = input ("Login or Register: ")
if option1 not in ("login", "register"):
begin()
begin()
Access()
reg(Ussername, Password, Age, Real_name, Last_name, Email)
CodePudding user response:
You need to pass all those input
strings into your reg
function. Change this:
print ("Enter all the info we will be asking you to register")
input ("Ussername: ")
input ("Password: ")
input ("Age: ")
input ("Real name: ")
input ("Last name: ")
input ("Email: ")
to this:
print("Enter all the info we will be asking you to register")
reg(
input("Ussername: "),
input("Password: "),
input("Age: "),
input("Real name: "),
input("Last name: "),
input("Email: ")
)
CodePudding user response:
They're not recognized because they don't exist.
You should save the user input and return it. Then, you read it when you execute the Access()
function, and pass it to reg()
.
from __future__ import with_statement
from asyncore import write
def reg(Ussername, Password, Age, Real_name, Last_name, Email):
global file
file = open ("User_details.txt","a")
file.write("\n" Ussername "," Password "," Age "," Real_name "," Last_name "," Email)
file.close
def login():
pass
def Access():
if option1 == "login":
input ("Ussername: ")
input ("Password: ")
input ("Age: ")
input ("Real name: ")
input ("Last name: ")
input ("Email: ")
login()
else:
print ("Enter all the info we will be asking you to register")
Ussername = input ("Ussername: ")
Password = input ("Password: ")
Age = input ("Age: ")
Real = input ("Real name: ")
Last = input ("Last name: ")
Email = input ("Email: ")
return Ussername, Password, Age, Real, Last, Email
def begin():
global option1
print ("Hi my name is Steve would you like to register or login")
option1 = input ("Login or Register: ")
if option1 not in ("login", "register"):
begin()
begin()
Ussername, Password, Age, Real, Last, Email = Access()
reg(Ussername, Password, Age, Real_name, Last_name, Email)
The same logic applies to the login part.