Bite 4: Validate user inputs and while loops | Python mystery game

preview_player
Показать описание
You can find all info about this bite here:

SUBSCRIBE to learn more about Power and Excel BI!

Our PLAYLISTS:

☼☼☼☼☼☼☼☼☼☼

POWER BI COURSES:

Want to learn Power BI? How about you take one of our courses? Here you can find the available courses:

☼☼☼☼☼☼☼☼☼☼

ABOUT CURBAL:

************

MY GEAR: You often ask me what software I use to edit my videos, so I thought I let you know in the description and give you a discount code so you can get it too!
COUPON: CURBAL10

Note, if you purchase the software using the link or code, I will receive a small commission and you will indirectly support my channel. Thanks in advance!

************

QUESTIONS? COMMENTS? SUGGESTIONS? You’ll find me here:
Twitter ► @curbalen, @ruthpozuelo

#CURBAL #SUBSCRIBE
Рекомендации по теме
Комментарии
Автор

This is SO cool! The pacing of these Bites is perfect; encouraging not overwhelming. I am now invested in the "game" 😀and waiting to see where this leads.

users-pRs
Автор

Hi Ruth I think the format of these Bites works really well! Just the right amount of learning in a bite-sized chunk 😊

staceybentham
Автор

Hi Ruth Started Python watching you videos really helpful !
Thanks for all your efforts

abhilashpatel
Автор

Great 🎉 I have been able to complete! It is nice to put in practice the concepts that I learned! The only issue is that I didn’t have access to the Jupyter notebooks which are only for member, but it has not been a problem to follow with my own notebook 😊
Looking forward next bite!

pilarbaldominos
Автор

Thank you, Ruth! I have been able to keep up so far! 😅 Comment/Question: Instead of the 'while/continue' approach, I tried adding an 'else:' statement in the username() function (from Bite 3) to call itself when the accept_challenge response is not 'yes' or 'no', and it seems to work the same way. I assume it's one of those '1001 ways to do a same thing' situations, but I am not sure if there is any issue with a function calling itself?

HachiAdachi
Автор

Hi ruth. please what is wrong with this code. thanks
# write a program that asks the user to enter 5 positive integers,
# the program disregards negative values and zeros and makes the user re enter an input if so.
# The program is capable of calculating both sum and product of all the numbers entered .
# after taking the inputs
# it asks the user whether they want to print the sum of the numbers
# or products and then shows the result accordingly

count = 0
sum = 0
product = 1
while count <= 4 :
numbers = int(input("Please enter 5 different inputs: "))
print()
count += 1
if numbers == 0 or numbers < 0 :
print("Please re-enter input")
else:
print("Would you like to multiply of add the total numbers")
choose = input("Choose to multiply or add now: ")
if choose == "add":
for x in range(numbers):
sum = sum + numbers
print(sum)
if choose == "multiply":
for x in range(numbers) :
product = product * numbers
print(product)

JokeJoshua