간단한 텍스트 기반 게임을 만들고있어 오류가 발생했습니다. 내 코드에서 int를 str로 변환해야합니다. 내 코드는 다음과 같습니다.if 문에서이 int를 문자열로 변환하는 방법은 무엇입니까?
tax1 = input("You May Now Tax Your City. Will You? ")
if tax1 == "Yes" or tax1 == "yes":
tax2 = input("How Much Will You Tax Per Person In Dollars? ")
if tax2 > 3:
print("You Taxed To High! People Are Moving Out")
time.sleep(1.5)
population -= (random.randint(2, 4))
print("The Population Is Now " + str(population))
time.sleep(1.5)
money += (population * 2)
print("From The Rent You Now Have $" + str(money) + " In Total.")
if tax2 < 3:
print("You Have Placed A Tax That Citizens Are Fine With.")
time.sleep(1.5)
money += (tax2+(population * 2))
print("From The Rent And Tax You Now Have $" + str(money) + " In Total")
내 코드에 어떻게 추가합니까?
오류 및 스택 추적을 게시하십시오. 오류가 있다고 우리에게 말하면 단지 도움이되지 않습니다. –
참고로, tax1 == "Yes"또는 tax1 == "yes"'대신'if tax1.lower() == "yes"'를 사용하고 싶을 것입니다. 사용자에게 더 많은 옵션 (대문자와 소문자의 조합). – thegrinner
세금이있는 이유는 도시를 잘 돌봐 줘야하기 때문입니다! –