python 3.5でbegin()タグを使用するには?つまり、テキストベースのRPGを作成しようとしているのですが、begin()タグを使用することは知られていません。実行するとPyシェルを迷惑メールにするからです。あなたはゾンビに遭遇しました!ゾンビには100個のHPがあります、あなたは攻撃しますか?そしてそれらのもの。python 3.5でbegin()タグを使用するには?
import time
import random
import sys
import time
global gold
global HP
gold = 0
print ('Welcome to Battle Deongeons')
myName = input('Whats your name?')
print ('Ok ' + myName + ' you need to kill monsters...')
choice = input("Do you want to play? Y/N")
if choice == "Y":
print('Lets start the Battle')
begin()
def begin():
global gold
global HP
print('Remember you can type "moves" to be reminded of the moves you have...')
print('To attack, type "Attack!".')
rewards=random.randint(1,3)
mob=random.randint(1,3)
if mob==1:
print('You ran into a Zombie!')
print('The Zombie has 100 HP!')
print('Do you attack?')
if choice == 'Attack!':
gold=gold+rewards
if mob==2:
print('You ran into a Headless Horseman!')
print('The Headless Horseman has 125 HP!')
print('Do you attack?')
if choice == 'Attack!':
gold=gold+rewards
if mob==3:
print('You ran into a Demon!')
print('The Demon has 130 HP!')
print('Do you attack?')
if choice == 'Attack!':
gold=gold+rewards
if gold > 100:
print ('You have killed all the monsters!')
play = input('Do you want to play again? Y/N?')
if choice == 'Y':
print('Then restart th program, silly!')
if choice == 'N':
print ('Okay, battle later')
sys.exit(0)
if choice == "N":
print ('Okay, battle later')
sys.exit(0)
こんにちは。あなたは噛むこと以上に噛まれてしまった。はるかに簡単なプログラムから始めましょう。あなたの年齢を聞かせて、<20の場合は何かを、20より大きい場合は何かを印刷してください。徐々に複雑にしてください。それぞれの変更の後、それをテストします。そして、インターネット上でいくつかのチュートリアルを見てください。プログラミングは楽しいですが、段階的に学習します。ところで、「タグ」はHTML(またはgrafitty)です。 Pythonではbegin()は関数と呼ばれます。 –