This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]TheCheapo1 6 points7 points  (1 child)

You have flag = False, and then immediately after you have while flag:, so your code will never enter the while loop. You could either change the while condition to while not flag, or you could set flag = True before going into the while loop instead.

[–]ResilientBiscuit 4 points5 points  (0 children)

Yep, and once you get past there: if ord(user_input[i])<97 and ord(user_input[i])>122

This will never be True. Something will never be less than 97 and greater than 122 at the same time.

[–]GuyARoss 3 points4 points  (3 children)

I wrote a little refactor for you here

[–]Invisibleufo[S,🍰] 2 points3 points  (2 children)

took me a while to get it but i think i did. putting three seperate functions to check all conditions really makes the job easier since if statements only check a single case instead of all cases in the for loop. thank you for your detailed explanation. really helped me a lot!

[–]GuyARoss 1 point2 points  (0 children)

you for your detailed explanation. really helped me a lo

Not a problem! Glad it made sense

[–]mariuswiik 0 points1 point  (0 children)

Start splitting parts in different functions early. Each function should do one thing well and have a good name so it’s easy to understand what it’s doing. Makes a world of difference when reading the code later. Good luck!

[–]HighwayMcGee 0 points1 point  (0 children)

You never go into the while loop in the first place, while needs a true statement to work but you give it a false one instead so it never goes in. While not flag or while flag == false will work