Py学习  »  问与答

帮忙看看,哪里错了,刚学摸着打了一段,运行不了

zxc晴天 • 6 年前 • 657 次点击  

帮忙看看,哪里错了,刚学摸着打了一段,运行不了,一直说else提示那里出错

hp= 100 welcome='welcome to heroes world' map=['#','#','#','#','#','#','#']

instruction=''' contrl your hero: 'a' for left 'd'for left'''

print(welcome) name= input('input your name:') hp =100

if not name: name='player01' usemsg={'name':name,'hp':hp}

print("your hero's name is",usermsg['name'],hp['hp']) print(instruction) piont=0

while 1: map[piont]="*" print('you are here',"".join(map)) usesinput=input('go or quit:')

if userinput =="d" and piont<6: map[piont]='#' piont +=1 elif userinput =="a" and piont>0: map[piont]='#' piont -=1 elif userinput =="qiut": print("goodbuy") break else: print("instruction")

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/4091
 
657 次点击  
文章 [ 1 ]  |  最新文章 6 年前
用户5650090558
Reply   •   1 楼
用户5650090558    6 年前

去掉else 前面的 break 就行了 这个是条件语句 不是循环 没必要用break吧