473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Formatted Input

Hi all,
I am a newbie to python
I have an input of form
<one numberspace <another number>
ie.
4 3
how can i assign these numbers to my variables??

Mar 10 '07 #1
2 2040
On Mar 10, 1:29 pm, "Deep" <deepblue...@gmail.comwrote:
Hi all,
I am a newbie to python
I have an input of form
<one numberspace <another number>
ie.
4 3
how can i assign these numbers to my variables??
n1, n2 = map(int, raw_input().split())

Mar 10 '07 #2
Deep wrote:
Hi all,
I am a newbie to python
I have an input of form
<one numberspace <another number>
ie.
4 3
how can i assign these numbers to my variables??
Or with list comprehension:

n1, n2 = [int(n) for n in raw_input().split()]

Neither of these methods checks for errors (e.g. non-integers)

-Larry
Mar 12 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Craig Thomson | last post by:
Do people generally try and output nicely formatted html from their scripts? I have been trying to, with variable indenting for tables etc. It makes it easier to see the html and perhaps debug...
4
by: Fabian | last post by:
I have a three tier nested array, used to define a map for a javascript game, and can be edited within the web page. Is there a way I can generate a visible copy of this array that I can then c&p...
6
by: Jason Heyes | last post by:
I am starting to worry about the performance of formatted read/write operations on data-redundant objects in my program.What can I do to improve this performance should it become an issue? ...
0
by: Jason Heyes | last post by:
I would like to report formatted input operations that fail. To achieve this I write messages that reflect failed operations to std::cerr. For example, #include <iostream> #include <string> ...
4
by: frogman042 | last post by:
My daughter is playing around trying to learn JavaScript and she wrote a small program that prints out a message in increasing and decreasing font size and color changes. She is using document...
2
by: Steven T. Hatton | last post by:
I'm still not completely sure what's going on with C++ I/O regarding the extractors and inserters. The following document seems a bit inconsistent:...
2
by: MLH | last post by:
Using A97, I have tables with 10-char text phone number fields to allow entry of xxxyyyyyyy phone numbers - where xxx is the 3-digit area code and yyyyyyy is the 7-digit phone number. I wish to...
3
by: funkyMonkey | last post by:
I'm binding date fields from entity objects and formatting the output in the text box in short date format. Code: BindDateField(Me.txtCheckIn, "Text", reservation.BookingDetail, "CheckIn")...
6
by: bfowlkes | last post by:
Hello, I am trying to parse two pre-formatted text files and write them to a different files formatted in a different way. The story about this is I was hired along with about 20 other people...
2
by: dkk | last post by:
I am new to C programming. I need to read data from a formatted input text file (column-based), for example, "12345abcde678", I want to parse it into "123", "45", "ab", "cde", "678", and write them...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.