Here's an example:
a = [] #a is an empty list
a.append(input()) #input is 5*5
print(a[0])
5*5
How can I print(a[0]) so it works out 5*5 with the result being 25? Is there any way? Thank you
Here's an example:
a = [] #a is an empty list
a.append(input()) #input is 5*5
print(a[0])
5*5
How can I print(a[0]) so it works out 5*5 with the result being 25? Is there any way? Thank you
The programmer in me hates the following piece of code but if you trust the input, it works well
print(eval(a[0]))
eval
tries to treat the string as an expression and evaluate it. In this case, the string '5*5'
is treated as simply the python expression 5*5
and outputs
25