Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exception handling on news source number input #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions News/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ def App():
for i in xrange(len(newsSources)):
print ("["+str(i)+"]" +"\t" +newsSources[i])
print ("Please enter the index of the news source or press 99 to quit")
newsSourceNumber = raw_input("News Source Number >>>> ")
try:
newsSourceNumber=raw_input("News Source Number >>>> ")
newsSourceNumber = int(newsSourceNumber)
except ValueError:
print ("That is not a valid News Source Number")
newsSourceNumber=int(newsSourceNumber)
continue
if newsSourceNumber==99:
sys.exit()
if (newsSourceNumber >=len(newsSources)):
print ("Please select the index no less than "+ str(len(newsSources)))
continue
newsSource = newsSources[newsSourceNumber]
obj=NewsPulling(newsSource)
Articles=obj.BeautifyArticles();
Expand Down