On 2013-08-06 03:48, Saad Javed wrote: > I want to add users to the tweet from the list, the no. of users added > based on the length of the tweet.
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())
pgpOYYsWsbV6Z.pgp
Description: PGP signature
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor