473,399 Members | 3,832 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,399 software developers and data experts.

How can a single line of user input be converted into multiple variables ?

For example:
info= input('Enter name address and telephone number\n')
I have tried declaring variables in advance ie.
var1 = " " var2 = " " var3 = " " but to no avail. Can you please help ?
Thanks in anticipation.
Jul 27 '10 #1

✓ answered by bvdet

If you are using Python 2.x, use raw_input(). To accomplish your task, the entered data must be formatted for parsing. Delimiting the data with commas will do nicely. Example, entering "Bill,101 Main St.,(888) 000-000":
Expand|Select|Wrap|Line Numbers
  1. >>> n,a,t = raw_input("Enter Name, Address, Telephone #").split(',')
  2. >>> n
  3. 'Bill'
  4. >>> a
  5. '101 Main St.'
  6. >>> t
  7. '(888) 000-000'
  8. >>> 

3 2816
bvdet
2,851 Expert Mod 2GB
If you are using Python 2.x, use raw_input(). To accomplish your task, the entered data must be formatted for parsing. Delimiting the data with commas will do nicely. Example, entering "Bill,101 Main St.,(888) 000-000":
Expand|Select|Wrap|Line Numbers
  1. >>> n,a,t = raw_input("Enter Name, Address, Telephone #").split(',')
  2. >>> n
  3. 'Bill'
  4. >>> a
  5. '101 Main St.'
  6. >>> t
  7. '(888) 000-000'
  8. >>> 
Jul 27 '10 #2
Many thanks for such a rapid solution ; the online articles
make no reference ,to the best of my knowledge, to multiple variables for input / raw_input.
Jul 27 '10 #3
dwblas
626 Expert 512MB
EasyGUI is a simple solution if you are entering parameters from the command line. If you are calling the program from another program and supplying parameters, then it obviously won't work. http://easygui.sourceforge.net/
Jul 28 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: noah | last post by:
Does PHP have a feature to associate Cookie sessions with a persistent database connection that will allow a single transaction across multiple HTTP requests? Here is how I imagine my process: I...
10
by: Johnny Lin | last post by:
Hi! Is there a way to automate the unbinding of multiple variables? Say I have a list of the names of all variables in the current scope via dir(). Is there a command using del or something...
12
by: agent349 | last post by:
Hi, I'm fairly new to c++. I need user input in the form of dollar amounts, ie: "$10.00". I'd like to remove the dollar sign "$" then store the rest in a variable. How do I go about removing the...
1
by: Ani | last post by:
Hi, I need to carry the user input across pages and then at the end insert all the values into the DB. How do I best accomplish this task in ASP.Net. I am a novice , please give me some simple...
0
by: Paulers | last post by:
hello VB masters I have an issue that I am hoping you can help me with. I am creating an application that accepts user input via a richtextbox. the user can enter multiple entries and I need to...
1
by: syntego | last post by:
I am using DB2 V8 fixpack 10 and have the following issue: >From a User Defined Function, I can assign multiple variables in a single statement as follows: -- Get the first update transaction...
2
by: Matt | last post by:
Hi, I'm ridiculously new to Access (about a week!) so please be patient! My database is a record of British Standards. Each has a unique identifier. Some are split into parts. I would like...
11
by: waffle.horn | last post by:
Hi, if this makes sense i want to create a function that can be called so that it reads a single line from a file, then after using the information destroys it. Such that when the function is...
7
by: vaiism | last post by:
I am creating a report that outputs the contact information and details about a water treatment plant, and needs to include information about people who work there. If I tie all the information...
4
by: Tarique | last post by:
Hello All. Is the following good enough to be a safe user input routine? What else should i do to improve it ? #include<stdio.h> #include<stdlib.h> #include<string.h> #define ARRAYSIZE 100 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.