Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is the code:
Python
print('This is a collection of useful programs.'
print('     _____')
print('|  |   |')
print('|__|   |')
print('|  | __|__')
print('Password Generator! This generator will make random passwords! Different every time!')
import string
from random import *
characters = string.ascii_letters + string.punctuation  + string.digits
password =  "".join(choice(characters) for x in range(randint(8, 16)))
print password
print('That's all for now!')

When I run the code it says invalid syntax. The word 'print' is invalid. Anyone know whats going on?
Posted
Updated 8-Mar-15 11:01am
v2
Comments
phil.o 8-Mar-15 17:02pm    
Maybe, in the last line, you have to escape the quote in That's.
print('That\'s all for now!')
Member 11457065 8-Mar-15 19:02pm    
Didn't work. Thanks though.
phil.o 8-Mar-15 19:07pm    
Otherwise, there's a missing closing parenthesis on the first line.

1 solution

A few minor syntax errors that the python IDE would have shown you.
Python
print('This is a collection of useful programs.')
print('     _____')
print('|  |   |')
print('|__|   |')
print('|  | __|__')
print('Password Generator! This generator will make random passwords! Different every time!')
import string
from random import *
characters = string.ascii_letters + string.punctuation  + string.digits
password =  "".join(choice(characters) for x in range(randint(8, 16)))
print (password)
print('That\'s all for now!')
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900