+ 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
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
+ 6
🤴🌹Cute Princess 🌹💐 unless I know what code coach is asking to do I can't ,wait for others
+ 4
Which code coach question is it?
+ 4
🤴🌹Cute Princess 🌹💐 copy the link of code coach and paste it in your question description
+ 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”.
+ 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!")
+ 3
Thank you so much all of them for helping me 💕💕🙏
Russ UTKARSH SAHA Hassan Khalil @vrintle RAHUL▪▪ {..Offline..}
+ 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”.
+ 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.
+ 2
I think this will work!!!!
https://code.sololearn.com/cxHm6adVBt6H/?ref=app
+ 2
🤴🌹Cute Princess 🌹💐
Thx for your complement...
+ 1
Abhay sorry there is no link of Code coach .
So please tell me where is code wrong?
+ 1
Abhay see this post
https://www.sololearn.com/post/723610/?ref=app
+ 1
Russ sir please see above tagged post for question
+ 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
+ 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.
0
Come I can help you
- 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