I just wondering how to make the code ising while or for loop can anybody share the coding.Q(land ho) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I just wondering how to make the code ising while or for loop can anybody share the coding.Q(land ho)

I already done it using if statement https://code.sololearn.com/ceYzar29RCMw/?ref=app

17th Jun 2022, 5:49 AM
Aisy Danish Mohd Nazry
Aisy Danish Mohd Nazry - avatar
10 Answers
+ 2
x=int(input()) if x>=20: print((((x//20)+1)*20)-10) else: print(10)
17th Jun 2022, 7:33 AM
JOKER
JOKER - avatar
+ 1
What you are trying to achieve?
17th Jun 2022, 6:11 AM
A͢J
A͢J - avatar
0
for z in range(int(input())): print(10 + (z//20)*20)
17th Jun 2022, 10:17 AM
Brian
Brian - avatar
0
Brian What your code is doing? Try running it once
19th Jun 2022, 9:55 AM
JOKER
JOKER - avatar
0
JOKER can you clarify your requirements? The code I posted meets the requirements to the best that I could interpret them.
19th Jun 2022, 3:13 PM
Brian
Brian - avatar
0
Brian See the output, is that what we want? https://code.sololearn.com/cnJYAr1rMAs2/?ref=app
19th Jun 2022, 3:25 PM
JOKER
JOKER - avatar
0
JOKER I can only reflect that question back. Is that code what you are looking for? If not, then please clarify your requirement. In what way do you wish to use a loop in the code?
19th Jun 2022, 3:44 PM
Brian
Brian - avatar
0
JOKER now I understand from your link that the OP must be asking about a newly-added Code Coach task. That gets us closer to the clarification we have been requesting. Thank you.
19th Jun 2022, 7:37 PM
Brian
Brian - avatar
0
Aisy Danish Mohd Nazry you could replace the floor division by 20 with a while loop that repeatedly subtracts 20.
19th Jun 2022, 9:47 PM
Brian
Brian - avatar
0
a = int(input()) boat = 1 plätze = 20 zeit1 = 10 zeit2 = 20 for i in range(a): plätze -= 1 if plätze == 0: boat += 1 plätze = 20 if boat == 1: print(zeit1) else: print(zeit1 + (zeit2 * (boat - 1)))
4th Jul 2022, 9:58 PM
Andreas Paar
Andreas Paar - avatar