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
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 =
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)
> >
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)