Answer the question
In order to leave comments, you need to log in
Python code not working, what should I do?
There is this code:
from pyrogram import Client
import time
i = 1
api_id = id
api_hash = "hash"
with Client("my_account", api_id, api_hash) as app:
while True:
try:
if i <= 68:
app.set_profile_photo(photo = "C:/Users/Block/Desktop/cat/f{i}.jpg")
i += 1
time.sleep(10)
else :
i = 1
except:
continue
C:\Users\Block\Desktop\Change-Avata>py main.py
File "main.py", line 12
while True:
^
IndentationError: expected an indented block
Answer the question
In order to leave comments, you need to log in
Read textbook. At least for dummies of younger preschool age.
You don't have a block of code after :
tabs Since python doesn't have semicolons or parentheses (mostly), correct tabs are important. Read carefully the errors that the interpreter throws out to you, everything is written there =)
This is how your code should have been:
from pyrogram import Client
import time
i = 1
api_id = id
api_hash = "hash"
with Client("my_account", api_id, api_hash) as app:
while True:
try:
if i <= 68:
app.set_profile_photo(photo = "C:/Users/Block/Desktop/cat/f{i}.jpg")
i += 1
time.sleep(10)
else :
i = 1
except:
continue
from pyrogram import Client
import time
api_id = id
api_hash = "hash"
with Client("my_account", api_id, api_hash) as app:
for i in range(68):
try:
app.set_profile_photo(photo = "C:/Users/Block/Desktop/cat/f{i}.jpg")
time.sleep(10)
except:
continue
from pyrogram import Client
import time
api_id = id
api_hash = "hash"
with Client("my_account", api_id, api_hash) as app:
for i in range(68):
app.set_profile_photo(photo = "C:/Users/Block/Desktop/cat/f{i}.jpg")
time.sleep(10)
You clearly wrote that the indent is not enough.
A little higher you have with - after it there should be indents.
Similarly with try-except a little further and if
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question