+ 7
Wants to implement/convert js to python,, the main issue is with the for loop; (can't iterate integer)
function solution(P, C){ let counter = 0; for(let x = 0; x < C; x++){ if( P > 1){ counter +=1; } P -= 2; } return "You can play: "+counter; } console.log(solution(102,102));
2 odpowiedzi
+ 6
~ swim ~ thanks mahn, while loop worked.
def solution(P, C):
counter = 0
x = 0
while x <= C:
if P > 1:
counter+=1
P-=2
x+=1
print "You can play: ",counter
solution(102,102)
+ 4
I'm pretty sure you can shared the wrong code, because iteration problems only show up with enhanced for loops