用Python编辑一个猜单词的程序,必须使用Function
1.Thesecondplayerhas7guessesasthereare7piecestothehangmanfigure.Thepiecesareaddedtothefigureinthefollowingorder:rope,head,torso,leftarm,rightarm,leftleg,rightleg.
2.Atthebeginningofthegamethefirstplayershouldbeaskedtoenterthesecretword.Allcharactersarelegalexcludingandwhitespacecharacters(tab,space,newline).Aftertheuserentersawordyoushoulddisplay30newlinessoastohidethesecretword.
3.Atthebeginningofeachroundyoushoulddisplayinthisorder:Thehangedman,thepartiallyguessedsecretword,thecharactersguessedsofar.
4.Forthesecretword,thecharactersthathavenotbeenguessedshouldbedisplayedas
5.Guessesforthecharactersinthesecretwordshouldbecaseinsensitive.Storetheenteredsecretwordinlowercaseandconvertallguessedcharacterstolowercase.
6.Leadingandtrailingwhitespaceshouldberemovedfromtheuser'sguessbeforecheckingit
7.Theusermustenteraguess.Iftheydonottheyshouldbetoldthattheymustenteraguessandreceivetheprompttoenterthenextcharacteragain.Thisshouldcontinueuntiltheuserentersanewcharacter.
8.Iftheuserguessesacharacterthattheyhavealreadyguessedthentheyshouldbetoldthattheyalreadyguessedthatcharacterandbegiventheopportunitytoguessagain.Thisshouldcontinueuntiltheuserentersanewcharacter.Theseguessesshouldnotbecountedagainsttheuser.
9.Theusercanonlyguess1characteratatime.Iftheuserentersmorethan1charactertheyshouldbetoldthattheycanonlyenter1characterandbegiventheopportunitytoguessagain.Thisshouldcontinueuntiltheuserentersanewcharacter.
10.Thelettersthathavebeenguessedsofarshouldbedisplayedinsortedorder.
11.Iftheuserguessesthesecretwordtheyshouldbetoldthattheyguessedthesecretword.
12.Iftheuserdoesnotguessthesecretwordtheyshouldbetoldthattheyfailedtoguessthewordandthewordshouldberevealed.
13.YouMUSTUSEFUNCTIONSforthisprogramandyoushouldapproachthisprobleminatopdownmanner.Yourprogrammusthaveatleastthefollowingfunctions.Theparametersyourfunctionaccepts