In python I have string examples as following:
str1= "True or False and True"
str2="6.4 * 32 + 43 -21+(3.4 + 2.0)"
now I want to learn both types of all elements of strings and learn the value of whole string
1)
for a in str1.split():
#write some code here and this will print the following output
#print(a and exact_type)
# a is True and type is bool
# a is False and type is bool
# a is True and type is bool
# and value of str1 is True type is bool
for b in str2.split():
# write some code here and this will print the following output
# print(a and exact_type)
# b is 6.4 and type is float
# b is 32 and type is integer
# b is 43 and type is integer
#value of str2 is 232.20000000000002 and type is float
I know all of them is of type string but I want to learn possible type, pure type
edit: clarification: i am trying to find a value of bunch of strings that is given me in this form. for example, str3="True + 34" will give me error. because it can not be evaluated. in string i could have various objects. integer, float, boolean, variable that is defined before etc. since all of them in a string I could not learn type of objects. I know all substring is of type string but I should get the type ignoring object is in a string