I need to know if I am using the following code correctly.

tweets = helpers.get_user_timeline(sys.argv[1], 50)

Immediately after this line of code, I check to make sure I found tweets with:

if tweets is None:
    sys.exit("Not a valid screen_name")

Upon running my code using several valid Twitter user names, my program exits with "Not a valid screen_name".

I am assuming that my code is not retrieving the tweets. Yes, I did remember to import helpers.

  • Are you passing the username with a preceding @? get_user_timeline() would not like this. Commented Mar 1, 2017 at 9:37
  • Had that problem for names containing @, I found .lstrip("@") in application.py, removes preceding @.
    – Blauelf
    Commented Mar 1, 2017 at 10:29

1 Answer 1


Thank you. Using .lstrip("@") did the trick.

  • Please don't add "thank you" as an answer. Instead, accept the answer that you found most helpful. - From Review
    – Cliff B
    Commented Mar 2, 2017 at 12:23
  • It would't let me accept either answer. It still won't unless I forgot how this works. Commented Mar 2, 2017 at 20:28
  • Thay can't be accepted because they're comments, not answers. Not your fault. Did you know that self-answers are not only acceptable but are encouraged? So, instead, can you please edit your answer and replace it with a description of what you did to correct the problem and then accept it? (You may have to wait up to 2 days to accept it.) That's the way to handle this! Happy coding!
    – Cliff B
    Commented Mar 2, 2017 at 23:48
  • Thanks for the tip, mate! Commented Mar 3, 2017 at 20:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .