> It looks like you're using Python 2, but you didn't specify. > > I'd probably do something like this: > > #!/usr/bin/env python > > MAX_LENGTH = 140 > > users = [ > "saad", "asad", "sherry", "danny", "ali", "hasan", "adil", > "yousaf", > "maria", "bilal", "owais", > ] > > def populate(): > message = raw_input("Enter string: ") > while users: > new_message = " ".join([message, "@" + users.pop(0)]) > if len(new_message) > MAX_LENGTH: > break > message = new_message > return message > > if __name__ == "__main__": > print(populate()) >
It will add max no. of users to one tweet until limit is reached. I want all users added to the tweet. E.g. if 4 users can be added to the tweet before reaching the limit, return three tweets...first two with 4 users attached and the last one with three. Think of it as sending the same tweet with all the users in the list mentioned. The code I posted does that but can only add 3 users at a time. I want it to be able to calculate maximum no of users it can attach to the tweet and then keep doing it until the list runs out. Hope i've explained my problem. And yes, i'm using python 2. Saad
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor