0

To young to ride

persons_ages = [] i = 0 while i<3: pers_age = int(input()) persons_ages.append(pers_age) i+=1 #your code goes here for i in range(10): if i > 17: print ("too young!") break else: print("Get ready!") It passes on case 1,2,4,5 Not sure why it does not pass on case 3

30th Nov 2021, 3:01 AM
Kim Hammar-Milliner
Kim Hammar-Milliner - avatar
9 Antworten
+ 8
Kim Hammar-Milliner , is this a sololearn code coach exercise? if yes, can you please mention the name of the tutorial and the lesson / exercise number? thanks!
30th Nov 2021, 6:10 PM
Lothar
Lothar - avatar
+ 2
Thanks that solved it..
30th Nov 2021, 4:50 AM
Kim Hammar-Milliner
Kim Hammar-Milliner - avatar
0
Here is the description The carousel is designed for 3 people who are each at least 16 years old. You are given a program that takes all 3 passengers' ages as inputs and inserts them in a list. Complete the program so that if it finds a value less than 16, it breaks the loop and outputs "Too young!". If the age requirement is satisfied, the program outputs "Get ready!". Sample Input 18 26 19 Sample Output Get ready!
30th Nov 2021, 3:02 AM
Kim Hammar-Milliner
Kim Hammar-Milliner - avatar
0
if i > 17: should be if I < 17:
30th Nov 2021, 3:21 AM
Simon Sauter
Simon Sauter - avatar
0
And instead of looping over i in the for loop you should loop over persons.ages.
30th Nov 2021, 3:23 AM
Simon Sauter
Simon Sauter - avatar
0
Here is my code, now it fails on case 2, 4 and passes 1,3,5 persons_ages = [] i = 0 while i<3: pers_age = int(input()) persons_ages.append(pers_age) i+=1 #your code goes here for persons_ages in range(10): if i > 16: print ("too young!") break else: print("Get ready!")
30th Nov 2021, 3:43 AM
Kim Hammar-Milliner
Kim Hammar-Milliner - avatar
0
Try this: for age in persons_ages: if age < 17
30th Nov 2021, 4:01 AM
Simon Sauter
Simon Sauter - avatar
0
That does not solve it.
30th Nov 2021, 4:18 AM
Kim Hammar-Milliner
Kim Hammar-Milliner - avatar
30th Nov 2021, 4:35 AM
Simon Sauter
Simon Sauter - avatar