Hi, I have a string that I want converted to an integer. I tried int() but it doesn't work because of what my string (as an example) is "2*2/4". I want it to make that into an integer and just put the answer (1).

Is there a simple way to do this? Thanks.

Recommended Answers

All 2 Replies

>>> eval("2*2/4") 1

commented: There you go. +3
commented: resourceful +1

>>> eval("2*2/4") 1

Ok thank you so much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.