+ 1
pull the trigger practice in python i'm confused about this code can anyone explain me with the answer
4 Respostas
+ 2
Thank you so much
+ 2
As a future reference, please use proper tags format 👍
https://code.sololearn.com/W3uiji9X28C1/?ref=app
+ 1
You didn't post the code so that makes it hard to explain without being able to see it.
+ 1
Guna Dhivya Varshini V
It is so simple. Just initialise a variable with value 100 and using loop just compare input value with given string like "hit" or "miss". If input value is equal to "hit" then add 10 in declared variable and if input value is equal to "miss" then subtract 20 from declared variable.
Since there are only 4 inputs so use while loop like this:
j = 0
while j < 4:
#take input here
# compare this input with hit or miss
# add 10 or subtract 20 based on condition from declared variable
j += 1
#finally print declared variable