While Loop and tuple in Python | find type of element and tuple with one element


While Loop and tuple in Python | find type of element and tuple with one element

Tuple in python : Tuple is a collection of Python objects separated by a comma. In some

 
instances a tuple indexing is similar to a list in terms of nested objects
 
and iterations, but is immutable as opposed to a tuple lists that are mutable.
 
Note: If a tule is produced with a single element, be sure to add a comma
 
after the element.
While Loop
 
With the while loop we can execute a set of statements as long as a condition is true.

# find type of element and tuple with one element

num=(1)

words=('one')

print(type(num))          # <class 'int'>
 
print(type(words))        # <class 'str'>

num=(1,)

words=('one',)

print(type(num))          # <class 'tuplt'>

print(type(words))        # <class 'tuple'>

Have any Question or Comment?

One comment on “While Loop and tuple in Python | find type of element and tuple with one element

[…] While Loop and tuple in Python | find type of element and tuple with one element […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories