Hi,
The script below is supposed to accept 8 letters maximum, and in case of input different from letter (for example an integer) a ValueError is raised and the while loop continue.
But when I run this part the program stops just after the error is raised, and the loop didn’t continue for the remaining input for iterated k.
Can you please help me figure out the reason?
Below the script and the output example (typing two letters and then a number)
import string
k=0
while k<8:
l = input("Please type a letter: \n")
k+=1
lslettres = list(string.ascii_letters)
if l not in lslettres:
raise ValueError("You didn't type a letter! \n")
continue;
type or paste code here
Please type a letter:
r
Please type a letter:
s
Please type a letter:
8
Traceback (most recent call last):
File “E:\AT CTN IP\Projet Py\Jeu du pendu\pendu.py”, line 11, in
raise ValueError(“You didn’t type a letter! \n”)
ValueError: You didn’t type a letter!