Skip to content
Sign upLog in
← Back to Community

Python spacing and tab issue

Profile icon
stevemiller

Sometimes, when I enter python code directly into repl.it, i run into Python errors where the indent or spacing is reported as uneven even if I've used the tab key.

I have a workaround. I copy and the paste a previous lines tabs. It's annoying to have to do this. I work in Python 3. Is this an issue with the repl.it editor wrt to spaces/tabs?

Voters
Profile icon
prajwaladhav11
Profile icon
Venkatasandeep
Profile icon
damiajewole
Profile icon
MadanKumar8
Profile icon
kanukuntlanithi
Profile icon
sravanivenum
Profile icon
VenkatraoPatapa
Profile icon
prasadk4
Profile icon
AvinashPanda
Profile icon
sri-saisai4
Comments
hotnewtop
Profile icon
totoeevee

sooooo yeah had this problem too
figured out how to fix it
so change indent type to tabs
highlight ALL your code
and DELETE IT
fixed
jkjkjkjk
so after u highlight all ur code, indent and then dedent with CMD/ctrl ] and then CMD/ctrl[.
it will auto format for you and yay

Profile icon
Jorgmassih

@totoeevee
thanks! It worked for me

Profile icon
v2couto

@totoeevee
im on windows

Profile icon
totoeevee

@v2couto
use control then
Ctrl ] then Ctrl [
if anyone is on mac use CMD ] then CMD [

Profile icon
v2couto

@totoeevee
ok thx

Profile icon
ShwetaJagdhane

Thanks man worked for [email protected]

Profile icon
HARDIKTIWARI

repl

what's the problem is?

Profile icon
arshdeep27singh

@HARDIKTIWARI
I am facing the same problem.

Profile icon
adipool02

@HARDIKTIWARI
I am also facing the same problem.

Profile icon
PriyankaMehta2

@HARDIKTIWARI
i am facing the same problem ..... have you found how to complete the task....

Profile icon
NeerajKhadagade

@HARDIKTIWARI
Try doing it with "Workaround Option 1" from this PDF "https://insidesherpa.s3.amazonaws.com/vinternships/companyassets/Sj7temL583QAYpHXD/repl_mod1_v4.pdf"

It worked for me! :)

Profile icon
RobertoBean

You don't need to copy and paste the tabs from previous lines. When you place a colon, then use the down arrow key to start typing on the next line, repl.it will automatically indent the correct amount of space for you. Also, if it's already indented out to a certain place, using the down arrow key again will keep it indented at the same level.

Profile icon
ChristopherPasa

I found in the settings when changing the indent type from spaces to tabs, the problem seemed to be fixed for me.

Profile icon
turroscott

The quickest fix is to use command F and highlight one of the tabs that you entered. Now replace these faulty tabs with one that was used in the previous lines.

Profile icon
ak11398

Still not able to fix this problem someone please help...........

Profile icon
Vivekanand12

return price_a/price_b
indentation error in this line

Profile icon
LaykenGombeda

go to settings and find indent type and change it or make sure it is set as tabs, then hit CTRL + F and hit SPACE and find the line that is bugging out your code and delete it and rewrite it with tabs, should work if not then ive got no clue

Profile icon
IsrarHusain

print("Ratio %s" %(getRatio(prices['ABC'],prices ['DEF'])))

Profile icon
nithishReddy6

,

Profile icon
Akhila0725

iam unable to use fork

Profile icon
SunnyKamalakar

Top-10-Laptop-Wallpapers-HD-Free-Download-Websites-Top-Ten-

Profile icon
DivyanshTrived1

if name == "main":

# Query the price once every N seconds.

for _ in xrange(N):
quotes = json.loads(urllib2.urlopen(QUERY.format(random.random())).read())
prices= {}
for quote in quotes:
stock, bid_price, ask_price, price = getDataPoint(quote)
prices[stock] = price
print ("Quoted %s at (bid:%s, ask:%s, price:%s)" % (stock, bid_price, ask_price, price))
print"Ratio %s" % getRatio(prices['ABC'], prices['DEF'])

Profile icon
DivyanshTrived1

@DivyanshTrived1
facing problem in prices={}

Profile icon
mayankkuamr001

Changing indent from spaces to tab helped me.

Profile icon
MKAMALI-IVCSEIV

WOWWW

Profile icon
Amrit-Baral

image


what the problem here??

Profile icon
avanish460

@Amrit-Baral
this is a tab indentation error

Profile icon
sujalkadam

yes ,it's big issue

Profile icon
IsrarHusain

key error ABC

Profile icon
UmaSrivally

@IsrarHusain
I'm getting the error, do u know how to resolve it?

Profile icon
PadmashreeJha

i am also facing