PYTHON TUPLE PROGRAM

 mytuple = ("this", 10.0, "is", "float", 3.6)


# Print value at index 0
print(mytuple[0])
# Print value at index 1
print(mytuple[1])
# Print value at index -1
print(mytuple[4])
# Print all the values from index 0
print(mytuple[0:5:1])
# Print all the values except the last value
print(mytuple[0:4:1])
print(mytuple[-1:-6:-1])

OUTPUT:
this
10.0
3.6
('this',·10.0,·'is',·'float',·3.6)
('this',·10.0,·'is',·'float')
(3.6,·'float',·'is',·10.0,·'this')


Comments

Popular posts from this blog

CONVERTING TUPLE INTO LIST AND LIST INTO TUPLE