I need help to make lot of random text to send on twitter but its too long copy paste any one know how i can duplicate (rdmlol == 0):
to 500 Thank
Code
if(rdmlol == 0):
api.update_status(status = 'coucou les toxic de ma tl feur ' str(TweetCount) ' je ne suis pas un robot lol allez voir feur ')
elif(rdmlol == 1):
api.update_status(status = 'coucou les pierre de ma tl feur ' str(TweetCount) ' je ne suis pas un robot lol allez voir feur')```
CodePudding user response:
You're probably looking for a for-loop over a range?
for _ in range(500):
msg = "coucou les toxic de ma tl feur " str(TweetCount) " je ne suis pas un robot lol allez voir feur"
api.update_status(status = msg)
If you need to construct a different message each time, the solution depends on what exactly do you need, e.g.
import random
def create_message(tweet_count, words):
# f-strings were introduced in Python 3.6
return f"coucou les {random.choice(words)} de ma tl feur {tweet_count} je ne suis pas un robot lol allez voir feur"
def update_status(api):
words = ["toxic", "pierre"]
for i in range(500):
msg = create_message(i 1, words)
api.update_status(status = msg)
I hope this helps.