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
10 Respostas
+ 2
x=int(input())
if x>=20:
print((((x//20)+1)*20)-10)
else:
print(10)
+ 1
What you are trying to achieve?
0
for z in range(int(input())):
print(10 + (z//20)*20)
0
Brian
What your code is doing?
Try running it once
0
JOKER can you clarify your requirements? The code I posted meets the requirements to the best that I could interpret them.
0
Brian
See the output, is that what we want?
https://code.sololearn.com/cnJYAr1rMAs2/?ref=app
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?
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.
0
Aisy Danish Mohd Nazry you could replace the floor division by 20 with a while loop that repeatedly subtracts 20.
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)))