Monday, March 23, 2020

tuple in python

n=input("enter a comma separated number:")
l=n.split(",")
t=tuple(l)
print("l=",l,"t=",t)
print(type(l),"\n",type(t))

output:
enter a comma separated number:2,3,4,5
l= ['2', '3', '4', '5'] t= ('2', '3', '4', '5')
<class 'list'>
 <class 'tuple'>

No comments:

Post a Comment

python class topic video