Write a program in python to input 4 items in a list and print their data type.
Answers
Answered by
10
l = list()
for i in range(4):
x = eval(input("Enter an element: "))
l.append(x)
print()
print()
print("Element\t", "Datatype")
for i in l:
print(i, "\t", type(i))
The eval() function was used along with the input() function, since the data to be input by the user could be of any datatype. eval() is preferred when you aren't sure of the datatype that will be input by the user. It accepts all the datatypes, and processes them accordingly.
type() is a function that specifies the datatype of the argument mentioned.
Equestriadash:
Thanks for the Brainliest! ^_^"
Answered by
3
That's rare XD
okay domed I will ask a question of 50 points u Answer it okay
Similar questions