0

我做了一个小程序来学习基础,我不明白为什么它不起作用所以你能帮我解释一下我的错误。欢迎每一个答案

import random
def gessing_game():
 t = 0
 r = random.randint(0,100)
 print(r)
 y = int(input("Please choose your number"))
 while  y != r:
  t = t + 1
  print("You have made",t,"attempts")
    if y > r:
     print("Too big!")
     y = int(input(print("Please try again")))
    if y < r:
     print("Too small!")
     y = int(input(print("Please try again")))
    if y == r:
     print("Well done you found it")
gessing_game()

这是他们如何定义我的错误

File "U:\Documents\Exo sur Thonny\Guessing_game.py", line 10
    if y > r:
   ^
IndentationError: unexpected indent
4

1 回答 1

0

Python 语法是基于缩进的。我也是 Python 编程的基础。它只是告诉你不需要在“if”后面添加任何缩进。当你添加缩进时,你只需打开一个块。

于 2018-10-19T11:13:02.517 回答