2016-06-13 7 views
-3

私はPythonの初心者です.2,4,10行目に入力が間違っていて、2番目の行の前に<を置くと、私はそれを承認します。私は種類のそれを少し変更したが、それはまだそれが言うライン12上のエラーを持って、それはそれを承認し、私は10行目のためにそれを試してみましたが、それはPythonの単語ゲームでエラーが発生する

start = int(input("type 1 to begin or 2 to buy items: ")) 
if start = 1 : 
    print("welcome to this game") 
if start = 2 : 
    ranged = 0 
    melee = 1 
    fighting = 0 
    money = 100 
    shop = int(input("1 for sword or two for arrows: ")) 
     if shop = 1 : 
      money = money-100 
      fighting = fighting+1 
      melee = melee+1 
      start = int(input("type 1 to begin or 2 to buy items: ")) 
     if shop = 2 : 
      money = money-100 
      fighting = fighting+0.5 
      ranged = ranged+1 
      start = int(input("type 1 to begin or 2 to buy items: ")) 
     else: 
     print("invalid selection")` 

ウムを動作しませんでした第四行のために>置きますxを認識することはできませんが、すでにこれを定義しています

start = int(input('type 1 to begin or 2 to buy items: ')) 
if start == 1 : 
    print("welcome to this game") 
    print("you will face off with a evil monster named york for the first adventure") 
    print("I am york and I will eat you") 
if start == 2 : 
    x = float(input('type 1 or 2 to buy items: ')) 
    ranged = 0 
    melee = 1 
    fighting = 0 
    money = 100 
if x == 1: 
    money = money-100 
    print(money) 
    fighting = fighting+1 
    melee = melee+1 
    start = int(input('type 1 to begin or 2 to buy items: ')) 
    if start == 1 : 
     print("welcome to this game") 
    else: 
     print("visit the shop another time") 
if x == 2 : 
    money = money-100 
    fighting = fighting+0.5 
    ranged = ranged+1 
    start = int(input("type 1 to begin or 2 to buy items: ")) 

答えて

1

Pythonの "="記号は次のとおりです。変数に値を署名します。 例:

>>> x = 3 
>>> x+1 
4 

比較のために "=="を使用してください。 例:

>>> if x == 3: 
...  print "That is true" 
... 
That is true 
>>> if x == 2: 
...  print "that is true" 
... 
>>> 
関連する問題