-6
# players stats and elements
player_health = 100
player_attack.earth = 20
player_attack.air =10
player_attack.fire = 15
player_attack.water = 12
ogre_health = 75
ogre_attack = 15
# main code
player_name = input('What is your name, Guardian? ')
print('Hello ' + player_name + ' the Guardian')
player_element = input('Would you like to be the Guardian of Air, Earth, Fire or Water? ')
if player_element == 'Air':
print('You have been granted the powers of the Air, Guardian.\
You now have the powers of the Wind and Sky.')
if player_element == 'Earth':
print('You have been granted the powers of the Earth, Guardian.\
You now have the powers of the Earth.')
if player_element == 'Fire':
print('You have been granted the powers of Fire, Guardian.\
You now have the powers of Fire. Do not destroy as you wish.')
if player_element == 'Water':
print('You have been granted the powers of Water, Guardian.\
You now have the powers to control the oceans and water.')
print('There is an enemy in the distance! What do you do?')
player_action = input('What do you do ' + player_name + '? ' + 'Type A to attack ')
if player_action == 'A':
enemy_health = enemy_health - power
print('The enemy\'s health is at ' + str(enemy_health) + ' Keep attacking!')
player_action = input('What do you do ' + player_name + '? ' + 'Type A to attack ')
if player_action == 'A':
if player_element == 'Water':
ogre_health = ogre_health - player_attack.water
print('The enemy\'s health is at ' + str(ogre_health) + ' Keep attacking!')
這是我的代碼。 它給我的錯誤cannot define player_attack.earth
爲什麼?我定義了它。這裏有什麼問題? 我正在使用python 3.4.3爲什麼我的變量沒有被定義?
請[編輯]你的問題,包括**全文**追溯的。使用'{}'代碼格式化按鈕來正確地格式化您的代碼。 – MattDMo
什麼是「playerAttack」?這是一堂課嗎?它是否已經有了「地球」字段? – Carcigenicate
即時通訊新的蟒蛇,所以我不知道太多。這是所有的代碼 –