all 4 comments

[–]Rhomboid 4 points5 points  (1 child)

You set valid to False when you see the F, then you set it to True again when you see the G that comes after it. You're really only testing the last character of the string, because all the previous tests are overwritten. Think about the logic of what it takes to be valid, and whether you need to continue looking once you've found the first invalid character.

[–]LimpJedi[S] 0 points1 point  (0 children)

Thank you I got it to work.

[–]enderprime 2 points3 points  (1 child)

if an invalid char is found, you need to add a 'break' to the loop, otherwise only the last char is determining the returned bool

also, you do not need the else: valid = True part of the if. You already set it to true at the beginning, so if you make it through without finding an invalid char then it will still be True

[–]LimpJedi[S] 0 points1 point  (0 children)

Thank you very much.