24th Oct 2023, 12:21 PM
Husna
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
24th Oct 2023, 5:06 PM
Lothar
Lothar - avatar
+ 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']
24th Oct 2023, 12:47 PM
Sean
Sean - avatar
+ 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.
24th Oct 2023, 2:37 PM
Wong Hei Ming
Wong Hei Ming - avatar