scanf(%d%d,&x&y) in python. How can I do it?

Recommended Answers

All 6 Replies

Usually you don't do it, you read and parse the input file by various means, for example

>>> import io
>>> stdin = io.StringIO("""34 78""")                                                                       
>>> line = stdin.readline()
>>> line
'34 78'
>>> x, y = (int(s) for s in line.split()[:2])
>>> x, y
(34, 78)

You could perhaps get a better answer by explaining in which context you want to do this.

I've to read two numbers separeted by an space and the divide the second one by the first one.

Are you actually unable to read any of the dozens of books or hundreds of introductory web sites that show you how to do this? You are too lazy to Google this yourself, but you expect someone here to spoon feed you the answer to such a simple question.

commented: Maybe it's that new code system of "alternate teaching methods." +11

I have been searching for days but i am not able to find nothing

If you've been searching for days for how to input two numbers and divide one by the other, and you haven't had any luck, then I suggest a career in anything that doesn't involve either computer programming or the internet.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.