I'm a beginner programmer trying to write a python script that will generate random passwords. However, I always get a non-ASCII character error even though I declared the coding #utf-8, as mentioned in another similar question here in Stack Overflow. This is the source code:
import string
import random
#coding: utf-8
print "Password generator will create a random customizable password."
print "Choose your options wisely."
number = int(input("How many letters do you want in your password?"))
caps = str(input("Do you want capital letters in your password? Y/N"))
symbols = str(input( "Do you want punctuation, numbers and other symbols in your password? Y/N"))
punctuation = ("!", ".", ":", ";", ",", "?", "'", "@", "£", "$", "«", "»", "~", "^","%", "#", "&", "/", range(0, 11))
lowercase = string.ascii_lowercase
uppercase = string.ascii_uppercase
if caps == "N":
characters = lowercase
else:
characters = uppercase + lowercase
if symbols == "Y":
characters += punctuation
password = random.sample(characters, number)
print "The password is", password "."
This is the terminal output
pedro@pedro-Inspiron-3521:~/Desktop$ python passwordgenerator.py
File "passwordgenerator.py", line 9 SyntaxError: Non-ASCII character '\xc2' in file passwordgenerator.py on line 9, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
I checked the link but I couldn't understand a thing, maybe because I'm not a native english speaker and since I started programming not long ago.Thanks in advance for your help.