Python:获取函数错误,Unindented错误

时间:2013-10-12 21:35:23

标签: python indentation python-3.1

我是Python的新手,我正在尝试将我的字符串更改为'abc'为'def',简而言之,我一直得到,"unindented does not match any other indentation level."因此,这意味着我的函数出了什么问题?

def changes(x):

   if 'a' in sent:
       x=sent.replace('a','d')

    if 'b' in x:
        y=x.replace('b','e')

    if 'c' in y:
        z=y.replace('c','f')
    print(z)

sent=print(input('Enter a sentence:'))

changes(x)

2 个答案:

答案 0 :(得分:0)

请检查缩进。你不能像在其他语言中那样写任何东西。

阅读此short guide.

答案 1 :(得分:0)

我已经并且仍然有很多这些错误。我发现真正有用的是打开所以我可以看到隐形或空白。在从Web上的代码上复制片段,或者在使用空格键和制表符进行更改以创建缩进时,这可能会导致缩进问题

检查发送的是否'a',以及下面的行。似乎比后续案例使用更少的空间。