[BangPypers] scanf replacement in python
kracekumar ramaraju
kracethekingmaker at gmail.com
Sun Nov 6 07:29:18 CET 2011
Hello
The question might be simple, but it has a trick.
*
*
*c code*
*scanf("%d, %d", &m,&n)*
The code can accept two nos separated by a space.
*Question*: What is the equivalent in python?
*Answer 1:*
*a, b = int(raw_input('no 1: ')), int(raw_input('no 2: '))*
*Shortcoming*: I need press return to get o/p of second no.
*Answer 2:*
a = raw_input("no; ")
#Enter two nos separated by space
a = a.split()
*Shortcoming*: it involves split function.
Is there any better way to approach the same problem.
--
*
"Talk is cheap, show me the code" - Linus Torvalds
Winning Regards
KraceKumar.R
http://kracekumar.wordpress.com
+91-97906-58304
*
*+91-85530-29521*
*
*
More information about the BangPypers
mailing list