-1

Here's what I mean:

foo = 25

bar = (raw_input("foobar: "))

print bar

And if "foo" is used as input, I want it to print 25 instead of "foo". Is this possible? How can I do this?

(I'm currently working in Python 2.)

Taufiq Rahman
  • 5,600
  • 2
  • 36
  • 44
dosso
  • 1

1 Answers1

0

Use the eval() command:

foo = 25
bar = eval(raw_input("enter 'foo': "))
print (bar)
ANVGJSENGRDG
  • 153
  • 1
  • 8