Do we have some inbuild function in python 2.7.9 which gets input both in integer & string using same function -
i using python 2.7.9 , new stack overflow.
input()
used getting integer input user.
raw_input()
used getting string input user.
i looking common function in python 2.7.9 allow user input either integer or string based on user wish
i using below code:
a=input("enter string") error: traceback (most recent call last): file "c:/users/eubcefm/desktop/important/python/2407/test.py", line 1, in <module> a=input("enter string") file "<string>", line 1, in <module> nameerror: name 'and' not defined
you can use raw_input() , try convert int.
rawinput=raw_input("enter string :") try: value=int(rawinput) except valueerror: value=rawinput print "type ", type(value) print "value ", value
Comments
Post a Comment