D
D
Dmitry Khakrin2021-12-02 02:48:11
Python
Dmitry Khakrin, 2021-12-02 02:48:11

How to fix the algorithm non-execution problem?

I start the program, when a character is selected, the program ends, although it should continue to display text and an input field, how to decide?
import random

import random

class Dog:
 def __init__(self, name, age):
 self.name = name
 self.age = age
 #print('Ишак создан')

 def sit(self):
 print(self.name.title + ' сел ')
 
 def jump(self):
 print(self.name.title + ' прыгнул ')
 
 def death(self):
 print(self.name.title + ' Ваш помер ')

 def fight(self):
 print('На' + self.name.title + 'Напали' + random.randint(1, 30) +'живодера')

angryM = Dog('Злой пес Миша' , 18)
chechenM = Dog('Миша Чеченец ' , 31)
kolM = Dog('Сын Колесниковича и Миши' , 7)

print('Cимулятор Миши')
print('1 - Злой пес Миша')
print('2 - Миша Чеченец ')
print('3 - Сын Колесниковича и Миши')
operation=input('Выберите персонажа:')

if operation == 1:
 print('Вы выбрали' + angryM.name)
 ang=input('продолжайте бегать ...')
 if ang == '1':
 angryM.fight

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-12-02
@degrater

operation=input('Select character:')
if operation == 1:
input() returns only strings. So it will return '1', '2' or '3' which is not the same as 1, 2 or 3.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question