Re: Transforming a str to an operator

2009-08-28 Thread Duke Normandin
On Fri, 28 Aug 2009, Ben Finney wrote: > Duke Normandin writes: > > > Hey > > > > I'm a Python noob > > > > So far so good! > > > > I've written the following: > > > > num1 = raw_input('Enter the first numb

Re: Transforming a str to an operator

2009-08-28 Thread Duke Normandin
On Thu, 27 Aug 2009, r wrote: > On Aug 27, 10:52 pm, Duke Normandin wrote: > > How do I convert the contents of "op" from a string to an actual > > arithmetic operator? eval() does not seem to be the answer. TIA! > > > Try this.. > > >>> op = &#x

Re: Transforming a str to an operator

2009-08-28 Thread Duke Normandin
On Thu, 27 Aug 2009, Stephen Hansen wrote: > > > > num1 = raw_input('Enter the first number: ') > > num2 = raw_input('Enter the second number: ') > > op = raw_input('Select one of the following [+-*/]: ') > > print 'The answer is: ', int(num1), eval(op), int(num2) > >

Transforming a str to an operator

2009-08-27 Thread Duke Normandin
Hey I'm a Python noob So far so good! I've written the following: num1 = raw_input('Enter the first number: ') num2 = raw_input('Enter the second number: ') op = raw_input('Select one of the following [+-*/]: ') print 'The answer is: ', int(num1), eval(op), int(num2)