Hi,
Please see the attached screenshot of my terminal to see what the issue is? ?
[Image: gran1_zpsxom4zzpe.png]
Ideally, the program should keep running if "BYE" is entered 3 times, not in a row/consecutive.
I'm lost what to add in my code so the program will ONLY end if "BYE" is entered 3 times in a row.
Thank you in advance.
=============================================================================================
Here's the exercise that I've been trying to do: ?
# Deaf grandma. Whatever you say to Grandma (whatever you type in), she should respond with this: HUH?! SPEAK UP, GIRL!
# unless you shout it (type in all capitals). If you shout, she can hear you (or at least she thinks so) and yells back:
# NO, NOT SINCE 1938!
# To make your program really believable, have Grandma shout a different year each time, maybe any year at random between 1930 and 1950. (This part is optional and would be much easier if you read the section on Python’s random number generator under the Math Object.) You can’t stop talking to Grandma until you shout BYE.
# Hint: Try to think about what parts of your program should happen over and over again. All of those should be in your while loop.
# Deaf grandma extended. What if Grandma doesn’t want you to leave? When you shout BYE, she could pretend not to hear you. Change your previous program so that you have to shout BYE three times in a row. Make sure to test your program: if you shout BYE three times but not in a row, you should still be talking to Grandma.
=============================================================================================
Here's my code: ?
Please see the attached screenshot of my terminal to see what the issue is? ?
[Image: gran1_zpsxom4zzpe.png]
Ideally, the program should keep running if "BYE" is entered 3 times, not in a row/consecutive.
I'm lost what to add in my code so the program will ONLY end if "BYE" is entered 3 times in a row.
Thank you in advance.
=============================================================================================
Here's the exercise that I've been trying to do: ?
# Deaf grandma. Whatever you say to Grandma (whatever you type in), she should respond with this: HUH?! SPEAK UP, GIRL!
# unless you shout it (type in all capitals). If you shout, she can hear you (or at least she thinks so) and yells back:
# NO, NOT SINCE 1938!
# To make your program really believable, have Grandma shout a different year each time, maybe any year at random between 1930 and 1950. (This part is optional and would be much easier if you read the section on Python’s random number generator under the Math Object.) You can’t stop talking to Grandma until you shout BYE.
# Hint: Try to think about what parts of your program should happen over and over again. All of those should be in your while loop.
# Deaf grandma extended. What if Grandma doesn’t want you to leave? When you shout BYE, she could pretend not to hear you. Change your previous program so that you have to shout BYE three times in a row. Make sure to test your program: if you shout BYE three times but not in a row, you should still be talking to Grandma.
=============================================================================================
Here's my code: ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import random no_goodbye = 0 while no_goodbye < 3 : name = input ( "[Deaf Grandma] Hi! What is your name?: " ) if name.isupper() is True : print ( "[Grandma shouting] NO, NOT SINCE" + " " + str (random.randint( 1930 , 1951 )) + "!" ) else : print ( "[Grandma shouting] HUH?! SPEAK UP, GIRL!!!" ) if name = = "BYE" : print ( "[Grandma shouting] I STILL WANT TO TALK TO YOU!" ) no_goodbye + = 1 |
Blockchain Visionary & Aspiring Encipher/Software Developer
me = {'Python Learner' : 'Beginner\'s Level'}
http://bit.ly/JoinMeOnYouTube
me = {'Python Learner' : 'Beginner\'s Level'}
http://bit.ly/JoinMeOnYouTube