How to add multiple lines of text in tweepy in one tweet

47 Views Asked by At

I'm trying to make a twitter bot that post once daily. I want it to say "Day 1" as well as the hashtag under it. Such as "Day 1 Ex3" How could I make this happen?

#Options For Hashtag
hashtag = {
    "0": 'Ex1', 
    "1": 'Ex2', 
    "2": 'Ex3', 
    "3": 'Ex4', 
    "4": 'Ex5'
}

day = 0
day_add = day = day + 1
day_num = "Day ", day_add


client.create_tweet(text = random.choice(list(hashtag.values())))

I've tried to do things such as client.create_tweet(text = random.choice(list(hashtag.values(), (day_num)))) and client.create_tweet(text = day_num, random.choice(list(hashtag.values()))) Neither work And yes, before this gets removed or downvoted, I have looked at How to tweet multiple lines with Tweepy? and some others, none seem to answer my question though

1

There are 1 best solutions below

0
Irtza Shahan On

you can do this,

#Options For Hashtag
hashtag = {
    "0": 'Ex1', 
    "1": 'Ex2', 
    "2": 'Ex3', 
    "3": 'Ex4', 
    "4": 'Ex5'
}

day = 0
day_add = day = day + 1

day_num = "Day ", day_add

random_hashtag = random.choice(list(hashtag.values()))

tweet_text = day_num + "\n" + random_hashtag 

client.create_tweet(text = tweet_text )

note: that \n means new line so hashtag is in next line then the day num.