> ...or, better, remove the if...break and just do: > > while users and len(new_message) + len(add) <= MAX_LENGTH: >
That causes: Enter string: These are my friends living in the same city as i am. I have known them for years. They are good people in general. They are: Traceback (most recent call last): File "chris_tweet_len.py", line 44, in <module> print("\n".join(generate_tweets(message, users))) File "chris_tweet_len.py", line 31, in generate_tweets while users and len(new_message) + len(add) <= MAX_LENGTH: UnboundLocalError: local variable 'new_message' referenced before assignment And the earlier fix now adds two users to a tweet, then one user, then two user, then one... :(
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor