D
D
Dmitry2022-03-06 16:25:07
Python
Dmitry, 2022-03-06 16:25:07

Invalid literal for int() with base 10:instagram, how to fix?

Tell me how to fix this error, I want to check who is subscribed to my Instagram page and who is not and unsubscribe from them.

Error code

<module>
    followers_count, following_count = int(''.join(followers_count.split(','))), int(''.join(following_count.split(',')))
ValueError: invalid literal for int() with base 10: ''


swears at this line
followers_count, following_count = int(''.join(followers_count.split(','))), int(''.join(following_count.split(',')))


The whole code, if the number of subscribers is more than 999, remove commas from the number
if ',' in followers_count or following_count:
    followers_count, following_count = int(''.join(followers_count.split(','))), int(''.join(following_count.split(',')))
else:
    followers_count, following_count = int(followers_count), int(following_count)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Chetchasov, 2022-03-06
@TalismanChet

Can you please provide the code of the entire module, otherwise it is not clear what content is in followers_count and where it came from.
If I managed to answer your question in the comments to this answer, then please mark my answer with a tick. Thanks

S
soremix, 2022-03-06
@SoreMix

1. The condition is written incorrectly, it will always be fulfilled.

if ',' in followers_count or ',' in following_count:

2. The error says that as a result followers_countor following_countcontain empty lines. How there was no data there - this is already a question for the code from which page such data was obtained

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question