import url REPOSITORY = 'http://www.cs.virginia.edu/~cs1112/text/' reply = input( 'enter file name: ' ) link = REPOSITORY + reply text = url.get_text() reply = input( 'enter indices: ' ) index_strings = reply.split() #all string numbers words = text.split() for i in index_strings: i = int( i ) word = words[ i ] print( word )