#tabs and spaces

54 messages · Page 1 of 1 (latest)

hollow needle
#

elif choice == 4:
try:
all_users = []
active_users = []
for index, member in enumerate(members):
print(f"{index+1}/{cont}", end="\r")
all_users.append(member)
if index % 100 == 0:
sleep(3)
if not member.bot:
if isinstance(member.status, (UserStatusRecently, UserStatusOnline, UserStatusLastWeek, UserStatusLastMonth)):
active_users.append(member)
elif isinstance(member.status, UserStatusOffline):
d = member.status.was_online
for i in range(0, 30):
current_day = today - datetime.timedelta(days=i)
correct_user = d.day == current_day.day and d.month == current_day.month and d.year == current_day.year
if correct_user:
active_users.append(member)

all_users = []
TabError: inconsistent use of tabs and spaces in indentation

haughty pine
#

!format

neon trenchBOT
#
Code Formatting

When sharing code with the community, please use the correct formatting for ease of readability.

Example

```py
YOUR CODE HERE
```

Those are back ticks not single quotes, typically the key above TAB

haughty pine
#

@hollow needle

hollow needle
haughty pine
#

`

#

copy paste

#

but there's an indentation error

#

make sure everything you want underneath each other is directly in line

hollow needle
#
        try:
            all_users = []
            active_users = []
    for index, member in enumerate(members):
        print(f"{index+1}/{cont}", end="\r")
        all_users.append(member)
        if index % 100 == 0:
            sleep(3)
        if not member.bot:
            if isinstance(member.status, (UserStatusRecently, UserStatusOnline, UserStatusLastWeek, UserStatusLastMonth)):
                active_users.append(member)
            elif isinstance(member.status, UserStatusOffline):
                d = member.status.was_online
                for i in range(0, 30):
                    current_day = today - datetime.timedelta(days=i)
                    correct_user = d.day == current_day.day and d.month == current_day.month and d.year == current_day.year
                    if correct_user:
                        active_users.append(member)```
#

@haughty pine is it ok like this

haughty pine
#

Well, firstly where is your "except block"

#

try must be accompanied by an except

hollow needle
#

elif choice == 4:
        try:
        all_users = []
         active_users = []
    for index, member in enumerate(members):
        print(f"{index+1}/{cont}", end="\r")
        all_users.append(member)
        if index % 100 == 0:
            sleep(3)
        if not member.bot:
            if isinstance(member.status, (UserStatusRecently, UserStatusOnline, UserStatusLastWeek, UserStatusLastMonth)):
                active_users.append(member)
            elif isinstance(member.status, UserStatusOffline):
                d = member.status.was_online
                for i in range(0, 30):
                    current_day = today - datetime.timedelta(days=i)
                    correct_user = d.day == current_day.day and d.month == current_day.month and d.year == current_day.year
                    if correct_user:
                        active_users.append(member)
    for member in all_users:
        if member not in active_users:
            write(group, member)
except:
    print(f"\n{r}There was a FloodWaitError, but check members.csv. More than 95% of members should be already added.")
f.close()
#

here i sent except

haughty pine
#

this for loop seems to be a problem

hollow needle
#

all_users = []
TabError: inconsistent use of tabs and spaces in indentation

#

this is the error

#

im not sure what to edit

haughty pine
#

the active_users is also a space in too much

hollow needle
#

ok so i remove one space

#

wait

#

idk why it sent like that but on my code it isnt like that

#

there is no extra space

haughty pine
#

You're probably going to need to indent everything in the try block too

#

as they are directly underneath

hollow needle
haughty pine
hollow needle
#

so i indent everything?

haughty pine
#

yeah, everything underneath the try block must be indented, as it is in the try block

#

the except must also be directly underneath the try

#

as everything is in the elif choise == 4: block

hollow needle
#

elif choice == 4:
try:
all_users = []
active_users = []
for index, member in enumerate(members):

#

it argues about the try line

haughty pine
#

no, the for must be IN the try block

#

that means indented

#
elif choice == 4:
  try:
    all_users = []
    active_users = []
    for index, member in enumerate(members):
      ...
hollow needle
#

like this?

#

ahh

#

ok

haughty pine
#

the if must also be in the try block, unless you want it to be executed in the for

hollow needle
#

omg

#

the indentation is alwyas different

#

sometimes small sometimes big

#

im having a headache

haughty pine
#

use tab

hollow needle
#

I am

#

Using tab is alwyas different

haughty pine
#

that's weird

#

I think it's trying to fit your code to be underneath itself

hollow needle
hollow needle
#

u see the distance is different