Python Forum
Why do I get Syntax error? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Why do I get Syntax error? (/thread-32124.html)



Why do I get Syntax error? - TechNitium - Jan-22-2021

#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.


RE: Why do I get Syntax error? - snippsat - Jan-22-2021

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: ")