这个猜字游戏非常简单,用random.randint() 产生一个1-20之间的随机数,用for in in range(6)来控制猜字的机会为6次,
这里需要注意的是input() 接受输入的是字符串,需要用int() 将其转换为整型, 具体可以看help(input)。
这样我们第一个猜字游戏就完成了,是不是很简单,试试循环部分用while你们看看需要怎么改???动手吧。。
input(prompt=None, /)
Read a string from standard input.The trailing newline is stripped. The prompt string, if given, is printed to standard output without atrailing newline before reading input. If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z Return), raise EOFError.On *nix systems, readline is used if available.
好不好都欢迎关注我,评论吐槽,一起进步。