Display a slice : Tuple Slice « Tuple « Python






Display a slice

Display a slice



inventory = ("a",
             "b",
             "c",
             "d")

begin = int(raw_input("\nEnter the index number to begin a slice: "))
end = int(raw_input("Enter the index number to end the slice: "))
print "inventory[", begin, ":", end, "]\t\t",
print inventory[begin:end]

           
       








Related examples in the same category

1.Tuple indexing and slicingTuple indexing and slicing