I am asking a user to enter a number, in which I want to print the item held at that index point in the list..
This is the code i currently have:
List = ["a", "b", "c", "d", "e", "f"]
print "The list has the following", len(List), "list:", List
new_item = raw_input("Which item would you like to add? ")
List.append(new_item)
print "The list has the following", len(List), "items:", List
Number = raw_input ("Please select a number: ")
Try converting
Numberto an integer first:Incidentally, it’s good Python style to make variables lower case, and keep identifiers that begin with a capital letter for classes. So, instead of
Listyou could usemy_listand instead ofNumberjust usenumber. (You shouldn’t uselistas a variable name since that will hide the built-inlisttype.)