我正在制作一个基于文本的游戏,并且一直做得很好,但现在我遇到了一个错误int
。到目前为止,我的代码如下所示:
money = 500
print("You Have $500 To Spend On Your City. The Population Is 0 People")
input_var3 = input("What Will You Spend Your Money On? A House Or A Restraunt. ")
if input_var3 == "House":
money - 100
print("You Have Spent Your Money On A House")
print("You Now Have $" + money)
if input_var3 == "Restraunt":
money - 150
print("You Have Spent Your Money On A Restraunt")
print("You Now Have $" + money)
你的钱等于 500 美元,但如果你把它花在房子或休闲场所上,你的钱会更少,而且外壳会打印出你还剩下多少。但是我总是得到这个错误:
Traceback (most recent call last):
File "C:\Users\Jason\Desktop\City Text.py", line 11, in <module>
print("You Now Have $" + money)
TypeError: Can't convert 'int' object to str implicitly
我已经意识到我必须做一个刺痛而不是 Int 但我不知道该怎么做。任何人都可以帮忙吗?