Answers for "eval python del"

2

eval function in python

T1 = eval(input('enter tuple:'))#tuple
D1=eval(input('enter dictionary:'))#dictionary
L1=list(T1)#L1 is assign as list
L2=list(D1)#list
L1.insert(3, '6')#insert method
print(L1)# list 6 inserted at 3rd index
L2.insert(2,'(8,9)')#keys,2 index (8,9) is inserted
print(L2)
#output
'''enter tuple:(1,2,3,4,5,6)
enter dictionary:{(1,2),(3,4),(5,6)}
[1, 2, 3, '6', 4, 5, 6]
[(1,2), (3,4), '(8, 9)', (5,6)]'''
Posted by: Guest on December-20-2021
0

eval in python

#string in another string
expr="'2+3'"
print(eval(expr))
print(eval(eval(expr)))
Posted by: Guest on July-10-2021

Python Answers by Framework

Browse Popular Code Answers by Language