While writing codes I tend to make mistakes and not notice it the I press enter and syntax error comes. I then select the entire code and press enter with the corrections but it tells me multiple statements syntax error what do I do? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

While writing codes I tend to make mistakes and not notice it the I press enter and syntax error comes. I then select the entire code and press enter with the corrections but it tells me multiple statements syntax error what do I do?

25th Aug 2016, 4:47 PM
Vishal Gali
Vishal Gali - avatar
5 Answers
+ 2
As I understand the code has to generate a password between 8 to 16 characters long using letters, digits and symbols. It actually worked on the app's console, but then I tried it on PC and it didn't. It might be due to different versions of python or software differences. It's better to start the For cycles at the beginning of a line. And the join.() method is more used for connecting strings with a separator. I simply added them to one another. Try this, it worked for me on PC: import string from random import * letters = string.ascii_letters digits = string.digits symbols = string.punctuation chars = letters + digits + symbols min_length = 8 max_length = 16 password = "" for x in range(randint(min_length, max_length)): password += choice(chars) print(password)
26th Aug 2016, 8:46 AM
Doc
Doc - avatar
+ 1
What's the exact code? It's hard to help without knowing the precise issue. There's a chance you didn't completely fix the errors.
25th Aug 2016, 10:17 PM
Doc
Doc - avatar
+ 1
import string from random import * letters = string.ascii_letters digits = string.digits symbols = string.punctuation chars = letters + digits + symbols min_length = 8 max_length = 16 password = "".join(choice(chars) for x in range(randint(min_length, max_length))) print(password)
26th Aug 2016, 1:58 AM
Vishal Gali
Vishal Gali - avatar
0
This is the corrected one
26th Aug 2016, 1:59 AM
Vishal Gali
Vishal Gali - avatar
0
Thanks Doc
26th Aug 2016, 9:38 AM
Vishal Gali
Vishal Gali - avatar