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
  use thing before self sylvanas 3 923 Jul-21-2021, 04:54 PM
Last Post: sylvanas
  Style question on adherence to PEP 8 with whitespace near an "=" sign nilesh 6 1,247 Jan-12-2021, 11:11 PM
Last Post: snippsat
  Syntax Error with = sign and more Kathleen57 3 1,227 May-03-2020, 03:52 AM
Last Post: buran
  Help with list thing please Yeyzon 1 1,291 Apr-19-2019, 07:51 AM
Last Post: snippsat
  Handling pound sign (#) within custom URL chisox721 5 3,294 Apr-02-2019, 10:01 PM
Last Post: chisox721
  Printing one thing from a list bidoofis 1 1,353 Feb-05-2019, 09:02 PM
Last Post: ichabod801
  Sign XADES-EPES Python pedro86porras 2 2,620 Nov-02-2018, 04:31 PM
Last Post: pedro86porras
  I found weird thing. catastrophe_K 1 1,271 Sep-29-2018, 09:59 AM
Last Post: gruntfutuk
  [Help] Using "Class" with User Input in an online sign up form vanicci 8 3,826 Aug-29-2018, 10:52 AM
Last Post: vanicci
  Make one thing act like another Zman350x 2 1,224 Aug-16-2018, 06:45 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

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