Python Forum
i making a terminal sign up website thing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
i making a terminal sign up website thing
#1
code

def username():
username = input("username:")
print("are you sure thats your username?")
YesNo = input("press t if thats your username press f if its not")
if YesNo == f:
username = input("username:")

username()

f = f

error

username:ken
are you sure thats your username?
press t if thats your username press f if its notf
Traceback (most recent call last):
File "C:\Users\user\PycharmProjects\pythonProject7\main.py", line 8, in <module>
username()
File "C:\Users\user\PycharmProjects\pythonProject7\main.py", line 5, in username
if YesNo == f:
NameError: name 'f' is not defined

Process finished with exit code 1
Larz60+ write Nov-04-2021, 09:46 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#2
Please use bbcode tags for your python code (you can press the python button above the editor).

(Nov-04-2021, 03:15 AM)Kenrichppython Wrote:
if YesNo == f:

This code checks if the variable YesNo has the same value as the variable f. But since you haven't assigned to the variable f yet, this is an error. I suspect you wanted to check if it was the string f. If so, you need to use quotes to define the string.

if YesNo == "f":
It is also a good idea not to use the same name for both a function and a variable in the function. Because they have different scope, this won't break immediately. But there are situations where this would cause confusion. Better to pick different names:

def username():
    username = input("username:") #username used as function name and string name
    ...
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Does @ at sign used for tother than decorators? ggpython000 1 497 Oct-12-2023, 09:08 AM
Last Post: buran
  I am confused with the key and value thing james1019 3 912 Feb-22-2023, 10:43 PM
Last Post: deanhystad
  Need help i just started the whole thing gabriel789 16 3,097 Sep-12-2022, 08:04 PM
Last Post: snippsat
  Need to sign JWT token with JWK key stucoder 1 1,649 Feb-21-2022, 09:04 AM
Last Post: stucoder
  use thing before self sylvanas 3 2,305 Jul-21-2021, 04:54 PM
Last Post: sylvanas
  Style question on adherence to PEP 8 with whitespace near an "=" sign nilesh 6 3,849 Jan-12-2021, 11:11 PM
Last Post: snippsat
  Not able to make a specific thing pause in pygame cooImanreebro 4 3,145 Dec-13-2020, 10:34 PM
Last Post: cooImanreebro
  Syntax Error with = sign and more Kathleen57 3 2,580 May-03-2020, 03:52 AM
Last Post: buran
  Help with list thing please Yeyzon 1 2,023 Apr-19-2019, 07:51 AM
Last Post: snippsat
  Handling pound sign (#) within custom URL chisox721 5 6,453 Apr-02-2019, 10:01 PM
Last Post: chisox721

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020