2017-06-18 1 views
0

ne pas comprendre comment obtenir la boucle d'arrêter et de continuer/répéter aussi, ne pas comprendre comment obtenir la deuxième partie de booléen travailleren boucle et booléenne

monthly_investment = float(input("Enter monthly investment:\t")) 
while monthly_investment < 1: 
    print("Entry must be greater than 0") 

yearly_interest_rate = float(input("Enter yearly interest rate:\t")) 
while yearly_interest_rate < 1 and yearly_interest_rate < 16: 
    print("Entry must be greater than 0 and less than or equal to 15") 
+1

https://www.tutorialspoint.com/python/python_while_loop.htm –

+0

je comprends la boucle tout simplement pas comment revenir en arrière si la valeur est o – Nimkora

+0

Retour à où? Si vous voulez faire quelque chose en fonction d'une condition, utilisez les instructions –

Répondre

0

Nimkora,

Vous avez juste besoin pour ajouter une autre instruction d'affectation à la fin de la boucle while afin que, une fois, l'utilisateur entre une entrée valide, le programme peut sortir de la boucle while.

monthly_investment = float(input("Enter monthly investment:\t")) 
while monthly_investment < 1: 
    print("Entry must be greater than 0") 
    monthly_investment = float(input("Enter monthly investment:\t")) 

yearly_interest_rate = float(input("Enter yearly interest rate:\t")) 
while yearly_interest_rate < 1 and yearly_interest_rate < 16: 
    print("Entry must be greater than 0 and less than or equal to 15") 
    yearly_interest_rate = float(input("Enter yearly interest rate:\t")) 
+0

im un idiot lol merci – Nimkora

+0

@Nimkora, lol ne vous inquiétez pas. Nous y avons tous été :) –