0
Append
Why is my append not working https://sololearn.com/compiler-playground/cpsbTcX94l7E/?ref=app
3 ответов
+ 4
Husna ,
as already mentioned by Wong Hei Ming , the indentation and also the mix of spaces and tabs should be fixed.
the indentation in this code has currently only 2 spaces per indentation level. readability is not as good as it could be.
> the python style guide (pep-0008) recommends to use *4 spaces* per indentation level. for more inforation from the style guide you can read this:
https://peps.python.org/pep-0008/#indentation
+ 3
The append works totally correct.
List before asking:
family members: ['abid', 'shabana', 'husna', 'amaan', 'haaniah']
List after asking:
family members: ['abid', 'shabana', 'husna', 'amaan', 'haaniah', 'aisha']
+ 3
The reason your code won't work because of the wrong indentation.
In line 11 you have a nested if statement, but that body is not indented.
The error message also point out the error, also where the error occurred.
File "./Playground/file0.py", line 12
print (name)
TabError: inconsistent use of tabs and spaces in indentation
Usually the error happens somewhere before the mentioned line.