Skip to content

Files

Latest commit

 

History

History
37 lines (25 loc) · 901 Bytes

File metadata and controls

37 lines (25 loc) · 901 Bytes

Pattern: Indentation contains mixed spaces and tabs

Issue: -

Description

Indentation has both tabs and spaces in it. Programmers should use either tabs or spaces, but not both.

Example of incorrect code:

Note: The character represents a space and the character represents a tab.

In this example, the third line contains four spaces and two tabs.

def get_name(self):
    if self.first_name and self.last_name:
••••→ → return self.first_name + ' ' + self.last_name
    else:
        return self.last_name

Example of correct code:

Change the line to use spaces only.

def get_name(self):
    if self.first_name and self.last_name:
••••••••return self.first_name + ' ' + self.last_name
    else:
        return self.last_name

Further Reading