Python Forum
HELP TabError: inconsistent use of tabs and spaces in indentation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HELP TabError: inconsistent use of tabs and spaces in indentation
#1
Hi there, i'm trying to print my code but it gives me this error:

Error:
File "C:\Users\jay\Desktop\asd.py", line 6 print("Checking in passenger: " + current_passenger) ^ TabError: inconsistent use of tabs and spaces in indentation [Finished in 0.1s with exit code 1]
Here is my code.
def passengers(not_checked_in, checked_in):
	"""Simulate passengers who are not checked in."""

	while not_checked_in:
		current_passenger = not_checked_in.pop()
		
        print("Checking in passenger: " + current_passenger)
        checked_in.append(current_passenger)

def show_checked_in_passengers(checked_in):
  print("\nThe following passengers have been checked in ")
  for passengers in checked_in:
     print(passengers)


not_checked_in = ["Jay Senyani"]
checked_in = []

passengers(not_checked_in, checked_in)
show_checked_in_passengers(checked_in)
I'm new at python so any help would be much appreciated :-)
Reply
#2
And what is that you don't understand in the message TabError: inconsistent use of tabs and spaces in indentation?

You cannot mix both tabs and spaces to create indentation. The recommended is to use spaces. All decent IDEs have an option to automatically make tab into 4 spaces (or whatever number of spaces you use, but 4 is recommended as per PEP8)

In addition - your indentation is inconsistent (again!) in lines 10-13, but that will be another error, when you fix the tab/spaces problem.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Now that u explained it i see what u mean. I fixed my problem. Thank you for helping newcomers to python! Have a great day.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Read csv file with inconsistent delimiter gracenz 2 1,140 Mar-27-2023, 08:59 PM
Last Post: deanhystad
  Inconsistent loop iteration behavior JonWayn 2 954 Dec-10-2022, 06:49 AM
Last Post: JonWayn
  ValueError: Found input variables with inconsistent numbers of samples saoko 0 2,432 Jun-16-2022, 06:59 PM
Last Post: saoko
  Buttons not working in tabs kenwatts275 2 1,336 May-02-2022, 04:45 PM
Last Post: kenwatts275
  PYQT charts in tabs frohr 10 4,223 Feb-13-2022, 04:31 PM
Last Post: Axel_Erfurt
  Loop Dict with inconsistent Keys Personne 1 1,576 Feb-05-2022, 03:19 AM
Last Post: Larz60+
  Inconsistent counting / timing with threading rantwhy 1 1,719 Nov-24-2021, 04:04 AM
Last Post: deanhystad
  Inconsistent behaviour in output - web scraping Steve 6 2,445 Sep-20-2021, 01:54 AM
Last Post: Larz60+
  Found input variables with inconsistent numbers of samples: [1000, 200] jenya56 2 2,806 Sep-15-2021, 12:48 PM
Last Post: jenya56
  Packages inconsistent warning during hdbscan install Led_Zeppelin 0 1,884 Aug-31-2021, 04:10 PM
Last Post: Led_Zeppelin

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020