-2

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)
khelwood
  • 55,782
  • 14
  • 81
  • 108
  • Rewrite your question. It looks awful. – Valentin Popescu Feb 11 '22 at 19:52
  • Welcome to stack overflow. Please [edit] your question to show how your code is formatted, and to include the full traceback of any error messages you are receiving. Also note that it is helpful to point out the specific problem code snippets, as stack overflow doesn;t include line numbers and that leaves us with trying to count lines to see which code you're referencing – G. Anderson Feb 11 '22 at 19:53
  • If line 38 is `reg(Ussername, Password, Age, Real_name, Last_name, Email)`, then it's telling you that none of those things you're trying to use as arguments is defined. You don't seem to know how variables work. You should probably go back to some kind of tutorial. – khelwood Feb 11 '22 at 20:04

2 Answers2

0

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: ")
        )
Samwise
  • 68,105
  • 3
  • 30
  • 44
0

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.

John Giorgio
  • 634
  • 3
  • 10