0

Python Pull the Tiger

I was using defind to do the code but something went wrong and could not give me the exactly result that i wanted to be. Can you guys check it out for me: #your code goes here def shooting_game(): score = 100 choice = 1 while choice <= 4 : type = input() if type == "hit": score += 10 if type == "miss": score -= 20 return score print(shooting_game())

15th Aug 2021, 9:50 AM
Huy Nhoz
Huy Nhoz - avatar
2 Antworten
+ 1
Huy Nhoz Indentation problem. 2nd if condition should be just below the 1st if condition like: if type == "hit": score += 10 if type == "miss": score += 20 Also increment choice by 1 inside loop https://code.sololearn.com/cC3kdlU8zc6q/?ref=app
15th Aug 2021, 9:55 AM
A͢J
A͢J - avatar
+ 1
The second if should be an elif and at the same indentation level as the first if. Also the return is indented 1 too many, I think.
15th Aug 2021, 9:56 AM
Lisa
Lisa - avatar