Как я могу зациклить код в python? Нужно чтобы этот код выполнялся установленное количество раз: def retweet_tweets():
try:
tweets = api.search(q=keyword, count=10)
for tweet in tweets:
if not tweet.retweeted:
tweet.retweet()
print("Retweeted: ", tweet.text)
time.sleep(2) # Pause for 2 seconds to comply with rate limits
except tweepy.TweepError as e:
print("Error occurred while retweeting:", str(e))
try:
tweets = api.search(q=keyword, count=10)
for tweet in tweets:
if not tweet.retweeted:
tweet.retweet()
print("Retweeted: ", tweet.text)
time.sleep(2) # Pause for 2 seconds to comply with rate limits
except tweepy.TweepError as e:
print("Error occurred while retweeting:", str(e))