227k views
2 votes
Declare a Boolean variable named isValid. Use isValid to output "Valid" if codeWord contains at least 3 letters and codeWord's length is greater than or equal to 8, and "Invalid" otherwise.

Ex: If the input is 12PH495y, then the output is:

Valid

Ex: If the input is WRyVKvN, then the output is:

Invalid

Note: isalpha() returns true if a character is alphabetic, and false otherwise. Ex: isalpha('a') returns true. isalpha('8') returns false.

User Buck Doyle
by
8.3k points

1 Answer

4 votes

Answer:

code : python

x = FDRTYDhfg123

ans = True

lettercount = 0

for letter in x:

 if type(letter) == str():

 lettercount += 1

 else:

 pass

if len(x) <= 8 and lettercount <= 3:

 ans = True

else:

 ans = False

print(ans)

Step-by-step explanation:

User Kannan Mohan
by
8.1k points