Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why do I get Syntax error?
#1
#getpass will hide what the person is typing during the password
import getpass

def new_entry():
  #input the username and password and the website
  Website = str(input("Enter the website: "))
  Username = str(input("Enter the username: "))
  Password = getpass.getpass()

#Menu to choose if you want to add, see or remove
print("  *************************")
print(" /$$   /$$ /$$$$$$ /$$$$$$$ \n| $$  | $$|_  $$_/| $$__  $$\n| $$  | $$  | $$  | $$  \ $$\n| $$$$$$$$  | $$  | $$  | $$\n| $$__  $$  | $$  | $$  | $$\n| $$  | $$  | $$  | $$  | $$\n| $$  | $$ /$$$$$$| $$$$$$$/\n|__/  |__/|______/|_______/ ")
print("**************************")
print ("1. See the list\n2. Add new entry")
choice = (input("")
if (choice) == (2):
  new_entry()
  #if you select option 2 it will call the new_entry code
else:
  choice = (input("ERROR\nInvalid input: Please type agian\n")
#Store this somewhere
So I get a syntax error on my if statement and I don't know why and if there is any why to improve this please tell me, I am trying to make a password saver.
Reply
#2
When get syntax error and can not see it on line it point to,look at line before.
So line in line 15 and 20 is missing one ) at end.

input() is returning a string so no need for str
Only in want int or float then use it like this int(input("Enter a number ")).
website = input("Enter the website: ")
TechNitium likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I have a syntax error! rohes_kaugummi 3 326 Jun-23-2021, 05:24 PM
Last Post: deanhystad
  import module with syntax error Skaperen 7 357 Jun-22-2021, 10:38 AM
Last Post: Skaperen
Heart near "(": syntax error Maryan 3 483 Jun-21-2021, 08:05 AM
Last Post: ibreeden
Exclamation getting a syntax error and i don't know why ilikedofs 10 762 May-13-2021, 08:52 PM
Last Post: deanhystad
  Even number code syntax error MrCeez 1 413 May-02-2021, 06:43 PM
Last Post: Larz60+
  error in your SQL syntax Xuli 10 720 May-02-2021, 12:27 PM
Last Post: Xuli
  Function syntax error Changosoyyo 2 557 Mar-07-2021, 10:42 PM
Last Post: Changosoyyo
  Syntax error on line 29 manwithjeans 3 614 Feb-27-2021, 08:28 AM
Last Post: perfringo
  Invalid syntax error - need help fixing calgk01 3 663 Feb-23-2021, 08:41 PM
Last Post: nilamo
  syntax error CompleteNewb 8 768 Jan-08-2021, 04:05 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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