0

Help me, please! Game python

I have tried to solve this problem in different ways, but can't solve it properly. Please help me, I want to see what the solution looks like "The game. The player starts with 100 points, with a hit adding 10 points to the player's score, and a miss deducting 20 points. The program must take as input 4 results of the action ("hit" or "miss"), calculate and output the remaining points of the player. Accepts 4 times Sample Output 110." My code https://code.sololearn.com/c5V7PBeg9w15/?ref=app

9th Jun 2021, 7:29 PM
Денис Изотов
Денис Изотов - avatar
5 Answers
+ 3
Hi! Please, show us your code attempt! Thx!
9th Jun 2021, 7:33 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
10th Jun 2021, 6:16 AM
Денис Изотов
Денис Изотов - avatar
+ 1
1. Назначить переменную, в которой будет хранится строковое значение выстрела. Сейчас ты пытаешься просто работать с командой ввода input(). Это так не работает. Команду надо связывать с переменной 2. Обрати внимание на условие цикла while. Опять же нам надо в условии сравнивать переменную и значение. Переменная может меняться, просто цифра у тебя меняться не будет никогда Исправляй пока это, потом пойдем дальше
10th Jun 2021, 10:39 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
Уже исправили, за тебя.
10th Jun 2021, 10:41 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
First your loop is endless, as the condition for while is 1 < 4 wich is always True: you must compare your variable i... Second, you are not storing the return value of input() call, but instead you are calling it at each comparison... wich let you with an unpredictacle number of input taken ^^ you rather should store the result of input call at start of the loop body and compare it with both valies: x = 100 i = 0 while i < 4: inp = input() i=i+1 if inp == "hit": x = x + 10 elif inp == "miss": x = x - 20 else: print(x)
10th Jun 2021, 10:39 AM
visph
visph - avatar