0

Returning EOF error for generate =input('would you like to generate a new password?')

import random import string print('hi, welcome to the password generator') upp_num = 0 int_num = 0 low_num = 0 sym_num = 0 upper_list =[] lower_list = [] symbol_list=[] num_list=[] for i in string.ascii_uppercase: upper_list.append(i) random.shuffle(upper_list) for j in string.ascii_lowercase: lower_list.append(j) random.shuffle(lower_list) for k in [0,1,2,3,4,5,6,7,8,9]: num_list.append(k) random.shuffle(num_list) for l in ['/','-','%',';','&','#']: symbol_list.append(l) random.shuffle(symbol_list) generate=' ' while not (generate[0].lower()=='y' or generate[0].lower()== 'n'): generate = input('would you like to generate a new password?') if generate[0].lower()== 'y': new_password= True else: new_password=False print('thank you, bye') while new_password: while not upp_num<6: upp_num = int(input('Please give your number of upper case letters maximum of five')) while not low_num<6: low_num= int(input('Please give your number of upper case letters maximum of five')) while not int_num<4: int_num= int(input('Please give your number of upper case letters maximum of three')) while not sym_num<4: sym_num= int(input('Please give your number of symbols, maximum of three')) pass_list= [] while upp_num: pass_list.append(upp_list.pop()) upp_num-=1 while low_num: pass_list.append(low_list.pop()) low_num-=1 while int_num: pass_list.append(int_list.pop()) int_num-=1 while symbol_num: pass_list.append(symbol_list.pop()) int_num-=1 break pass_string = str(pas_list) print(pass_string)

16th Apr 2020, 5:03 AM
Chris Chen
Chris Chen - avatar
9 odpowiedzi
+ 2
Codes with interactive input are tricky to run in SoloLearn, see the following code to understand how input works in SoloLearn. https://code.sololearn.com/WhiNb9BkJUVC/?ref=app
16th Apr 2020, 5:50 AM
Ipang
+ 2
visph Not a reproach to me at all : ) But given a choice, I would really appreciate it if the OP would share a saved code link, much more convenient for checking, compared to raw text 👌
16th Apr 2020, 8:11 AM
Ipang
+ 1
Ipang it seem's anyway that there's bugs in the code itself ;)
16th Apr 2020, 6:19 AM
visph
visph - avatar
+ 1
Chris Chen I don't promise I solve all problems in your code, but: + your "while new_password" loop never ends if initially set to True (because you never set it to False ^^)... quick fix: remove the line, unindent the block, and add "exit(0)" in the "else" block of your "if generate[0].lower()=='y'"; + the conditions of the "while" loops for inputing numbers are weird: what's your purpose? did you want that the number entered by user be lesser than X or greater or equals to X?... By doing "if NOT thing_num < X", you're doing "if X <= thing_num"... so as you initialize the variables to zero, that's never True, and the user is never asked for numbers ^^ + what do this "break" alone at the end of the "while symbol_num" loop block? + this last loop has two typo: first you need to replace "int_num-=1" by "sym_num-=1' else that will be an endless loop (if it start one day ;P), and second the variable name is "sym_num", not "symbol_num" in the "while" condition (or replace all other instances of "sym_num")
16th Apr 2020, 7:33 AM
visph
visph - avatar
+ 1
It'd help if you save it as a program and post the link here,
16th Apr 2020, 7:42 AM
Justus
Justus - avatar
+ 1
visph I didn't even check the code, I'm not even sure whether or not that code is truncated, being written with extra line breaks like that. EOFError is quite common for codes that require interactive input, something that isn't suitable in SoloLearn. So I just pass the OP Ulisses' code.
16th Apr 2020, 7:56 AM
Ipang
+ 1
Ipang sorry if my remark could be interpreted as a reproach: that was not my purpose ;) My goal was just to signal the possible misunderstanding of the question, and the probable necessity to investigate further ^^
16th Apr 2020, 8:06 AM
visph
visph - avatar
+ 1
Ipang Sure... that's the best way to increase probabilities to get helping answers ;)
16th Apr 2020, 8:19 AM
visph
visph - avatar
+ 1
Thank you all for the reply. I would try to modify the code and run it again on another platform to see if it works.
16th Apr 2020, 10:21 AM
Chris Chen
Chris Chen - avatar