+ 9

I stuck in a simple code anyone help me??

It is code coach questions here I got 4 correct in 5 . https://code.sololearn.com/cX22wbwFygsP/?ref=app See this question https://www.sololearn.com/post/723610/?ref=app

1st Nov 2020, 11:42 AM
🤴🌹Cute Princess 🌹💐
🤴🌹Cute Princess  🌹💐 - avatar
21 Antworten
+ 2
Check out this: Just placed the ` return "Get ready!" ` line after the for loop checking is done. https://code.sololearn.com/cbhOqB309J6o/?ref=app
3rd Nov 2020, 10:14 AM
777
777 - avatar
+ 6
🤴🌹Cute Princess 🌹💐 unless I know what code coach is asking to do I can't ,wait for others
1st Nov 2020, 11:56 AM
Abhay
Abhay - avatar
+ 4
Which code coach question is it?
1st Nov 2020, 11:44 AM
Abhay
Abhay - avatar
+ 4
🤴🌹Cute Princess 🌹💐 copy the link of code coach and paste it in your question description
1st Nov 2020, 11:50 AM
Abhay
Abhay - avatar
+ 4
Also, the title of the CC implies that it is trying to get you to used a (often overlooked) feature of for loops which is the else clause. The else clause is called if the for loop terminates as expected, meaning that it hasn’t been terminated early by a break statement. See this code snippet: for x in list_of_numbers: if x == 100: print(“Found 100”) break else: print(“No 100 found”) This will cycle through the list checking for the number 100. If it finds it, it will terminate the loop early, meaning that the else clause is not executed. If, however, 100 is not in the list, it will print “No 100 found”. The easiest way (I think) to think about this else clause is to consider it as “nobreak”.
1st Nov 2020, 12:24 PM
Russ
Russ - avatar
+ 4
🤴🌹Cute Princess 🌹💐 I hope you have solved your problem yet...☺ .. .. If not see your problem solution..below.. I assured you that it is easiest answer of all...🆒️✔ x = int(input()) x = int(input()) x = int(input()) if x<16: print("Too young!") else: print("Get ready!")
2nd Nov 2020, 6:11 PM
Mr. Rahul
Mr. Rahul - avatar
+ 3
Thank you so much all of them for helping me 💕💕🙏 Russ UTKARSH SAHA Hassan Khalil @vrintle RAHUL▪▪ {..Offline..}
5th Nov 2020, 6:53 AM
🤴🌹Cute Princess 🌹💐
🤴🌹Cute Princess  🌹💐 - avatar
+ 2
Your code will print “Get ready” if the first person is at least 16. You need to check that ALL people are at least 16 before printing “Get ready”.
1st Nov 2020, 12:06 PM
Russ
Russ - avatar
+ 2
First thing to know is, 'return' returns something and stop the function. So as soon as your code gets a return statement, it'll come out of otp. Actually your code is only checking the first element. You can solve this in multiple ways, think and try them out.
2nd Nov 2020, 9:16 AM
Md. Faheem Hossain
Md. Faheem Hossain - avatar
2nd Nov 2020, 9:23 PM
Edwin
+ 2
🤴🌹Cute Princess 🌹💐 Thx for your complement...
5th Nov 2020, 7:29 AM
Mr. Rahul
Mr. Rahul - avatar
+ 1
Abhay last after lesson in python
1st Nov 2020, 11:46 AM
🤴🌹Cute Princess 🌹💐
🤴🌹Cute Princess  🌹💐 - avatar
+ 1
Abhay sorry there is no link of Code coach . So please tell me where is code wrong?
1st Nov 2020, 11:55 AM
🤴🌹Cute Princess 🌹💐
🤴🌹Cute Princess  🌹💐 - avatar
1st Nov 2020, 12:00 PM
🤴🌹Cute Princess 🌹💐
🤴🌹Cute Princess  🌹💐 - avatar
+ 1
Russ sir please see above tagged post for question
1st Nov 2020, 12:05 PM
🤴🌹Cute Princess 🌹💐
🤴🌹Cute Princess  🌹💐 - avatar
+ 1
The issue was that it was returning too younge when the number was 16, where the question states that is an allowed age. This is what should work if I have understood. You had to remove the = in the operators to check if the number was below 16, not equal since that means that they are allowed and not too younge. https://code.sololearn.com/clx2A900PVT7/?ref=app
2nd Nov 2020, 4:07 AM
Cam UOR
Cam UOR - avatar
+ 1
Your code is only checking first input persons age If input : 11,23,19 are given it prints too young. If input 23,11,19 are given it prints Get ready. Modify code for checking whole list age greater than 15 , then at last return get ready or too young.
3rd Nov 2020, 9:10 AM
Nikhil Gupta
Nikhil Gupta - avatar
0
Come I can help you
3rd Nov 2020, 11:29 AM
Hassan Khalil
Hassan Khalil - avatar
- 1
I fixed it, you should to put your input outside the while loop, then try using string formation for variable 'j'. https://code.sololearn.com/cCUO9VhL6s5j/?ref=app
3rd Nov 2020, 11:21 AM
ZUL ISKANDAR BIN ZAINORHAN -
ZUL ISKANDAR BIN ZAINORHAN - - avatar