如何用PYTHON制作猜词语游戏
1、打开JUPYTER NOTEBOOK,新建一个空白的PY文档。

3、guess_this_word = "happy"guess = ""while guess != guess_this_word: guess = input("Please guess the word: ")print("You guess the word!")用WHILE就可以不断地询问让用户输入。

5、guess_this_word = "happy"guess = ""count = 0while guess != guess_this_word and count < 3: guess = input("Please guess the word: ") count = count + 1print("You guess the word!")一般新手会犯这样的错误,直接把条件全部输入。这样条件就直接回打印语句出来了。

7、guess_this_word = "happy"guess = ""count = 0count_limit = 3no_chance = Falsewhile guess != guess_this_word: if count < count_limit: guess = input("Please guess the word: ") count += 1 else: no_chance = Trueprint("You guess the word!")当我们增加TRUE和FALSE条件的时候就可以中断WHILE 了。

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:48
阅读量:42
阅读量:21
阅读量:49
阅读量:59