基肉吧 关注:309贴子:31,429
  • 15回复贴,共1

python hangman。救赎全世界sadaf的学生(save all UAstud)!

只看楼主收藏回复

first for Baidu
一楼百度


IP属地:浙江1楼2013-03-02 09:42回复
    main program
    主程序


    IP属地:浙江2楼2013-03-02 09:42
    回复
      words = ['cow', 'horse', 'deer', 'elephant', 'lion', 'tiger', 'baboon', 'donkey', 'fox', 'giraffe']print('welcome to Hangman! Guess the mystery word with less than 6 mistakes!')#guess number=ii=input('Please enter an integer number (0<=number<10) to choose the word in the list:')#defdef f(k): if k==1: return('------------\n| |') if k==2: return('------------\n| |\n| O') if k==3: return('------------\n| |\n| O\n| / |') if k==4: return('------------\n| |\n| O\n| / |\n| |') if k==5: return('------------\n| |\n| O\n| / |\n| |\n| / |') if k==6: k=k+6 return('------------\n| |\n| O\n| / |\n| |\n| / |\n| \n| \nToo many incorrect guesses. You lost!')
      def word(i): i=int(i) if i==0 or i==8: return('___') elif i==1 or i==5 or i==6 or i==7: return('_____') elif i==2 or i==4: return('____') elif i==3: return('________') else: return('_______')#checkingtry: x=int(i) except Exception as err: print('Input must be an integer!') i=input('Please enter an integer number (0<=number<10) to choose the word in the list:')if i==' ': print("Input must no be empty.") i=input('Please enter an integer number (0<=number<10) to choose the word in the list:')elif ((int(i)<0) or (int(i)>=10)): print('Index is out of range!') i=input('Please enter an integer number (0<=number<10) to choose the word in the list:')else: a=words[int(i)]L=0k=0#game b=len(a)print('the length of the letter is %s' %b)g=word(i)q=list(g)#mathch=m postion=palist=list(a)b=len(a)c1=' 'while k<6: c=input('Please enter the letter you guess:') if c1==c: c=input('Please enter the DIFFERENT letter you guess:') p=0 m=0 while p<b: if c!=alist[p]: p=p+1 else: q[p]=c m=m+1 p=p+1 if m!=0: L=m+L print('the letters is in the word') print('letters has matched so far:', ''.join(q)) c1=c if L==b: print('you win') break else: k=k+1 print('The letter is not in the word.') print(f(k)) c1=c


      IP属地:浙江3楼2013-03-02 09:42
      收起回复
        #我了个去怎么这么乱?
        #wtf for seq
        猜词小游戏,还是蛮有趣的
        hangman game work with fking fun
        第一次接触编程的课,觉得异常好玩啊,有点想转学电脑了= =老湿我要做中国人自己的galgame!


        IP属地:浙江4楼2013-03-02 09:45
        回复
          完全看不懂


          来自Android客户端5楼2013-03-02 13:25
          回复
            除了最后一句其他有种不明觉历的赶脚 - -


            IP属地:江苏6楼2013-03-02 14:38
            回复
              受B这是在干嘛


              IP属地:上海7楼2013-03-02 17:46
              收起回复
                战五渣表示完全不明所以


                9楼2013-03-02 22:54
                收起回复
                  我又想起来了三年前受B的小说的坑


                  IP属地:浙江来自Android客户端11楼2015-03-26 17:42
                  回复