How can I remove ' from the string '/' and use it for division in Python?
For example:
a='/'
b=6
c=3
bac
The answer should be 2.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Python has an
eval()function that can do this:However, please note that if you’re getting input from a remote source (like over a network), then passing such code to
eval()is potentially very dangerous. It would allow network users to execute arbitrary code on your server.