Create a Tuple in Python
#create a tuple:
a=("priya",5,5.6,"a","85",87,9,'python','machine')
print(a)
#print(a)
print(a[1])
print(a[-1])
print(a[-5])
print(a[2:4])
print(a[-5:-1])
#convert tuple into a list to be able to change it:
x=("vish","priya","war")
print(x)
y=list(x)
print(y)
y[1]="bov"
x=tuple(y)
print(x)
#for me in a:
# print(me)
#Create a Tuple:
a = ("mahesh", 5 , 5.6,"a" ,"85",6,87,9,'python','baba')
print(a)
#print(a)
print(a[1])
print(a[-1])
print(a[-5])
print(a[2:4])
print(a[-5:-1])
#Convert the tuple into a list to be able to change it:
x = ("bala", "mahesh", "war")
print(x)
y = list(x)
print(y)
y[1] = "bov"
x = tuple(y)
print(x)
for me in a:
print(me)
if "bala" in a:
print("Yes, 'bala' is in the nickname tuple")
else:
print("bala is not found the tuple")
print(len(a))
thistuple = ("bala",)
thistuple = ("bala",)
print(type(thistuple))
#NOT a tuple
thistuple = ("bala")
print(type(thistuple))
#del thistuple
print(thistuple)
tuple1 = ("a", "b" , "c",9,9.3,5631,"jsdbchfdvhndfvbfd")
tuple2 = (1, 2, 3, "gfjdjd bhjvbdhvb")
tuple3 = tuple1 + tuple2
print(tuple3)
list1 = (input("Enter: ")).split()
Comments
Post a Comment