Ask coding questions

← Back to all posts
TabError: inconsistent use of tabs and spaces in indentation
adsarebbbad (215)

at the bottom it says TabError: inconsistent use of tabs and spaces in indentation but i can't fix it. could someone please make a fixed version?

Comments
hotnewtop
PattanAhmed (1397)

@adsarebbbad Hi,
Ah...
There were a lot of bugs in your program.
Finally, I got rid of all of them.

Here is the fixed code:-

from colored import fg, attr
import time, sys
from time import sleep
import os

def sp(str):
  for i in str:
    sys.stdout.write(i)
    sys.stdout.flush()
    if ((i != "\n") and (i != ":")):
	    time.sleep(0.09)
    else:
	    time.sleep(0.6)
randomUsername = input(fg('red')+ "Type a random username\n>>")

def enter():
  input(fg('cadet_blueyellow'))
  os.system("clear")

while True:
  sp(fg('red')+"hello " + randomUsername)
  userInput = input("""
  [1] Go to shop
  [2] Play\n>>""")
  if (userInput == '1'):
    os.system("clear")
    userInput = input("""  
  Shop:  
  [1] Get a wooden sword
  [2] Back\n""")
    if(userInput == '1'):
      sp(fg('blue')+"You now have 1 wooden sword")
      enter()
			
  elif(userInput == '2'):
    os.system("clear")
    userInput = input("""
    You've decided to play      
    [1] Go to the lands
    [2] Back\n""")
    if(userInput == '1'):
      sp(fg('yellow')+"You have arrived at the lands")
      os.system("clear")

That's it
Thanks!

Hope this helps

DynamicSquid (4622)
	userInput = input("""
	[1] Go to shop
	[2] Play\n>>""")

I think that's causing the error. Maybe try to use your strings like this:

	userInput = input("[1] Go to shop\n[2] Play\n>>")