Python Forum
Taking user input and storing that to a variable then storing that variable to a list
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Taking user input and storing that to a variable then storing that variable to a list
#11
I gave you an example.
Define the function, and just use it when you have to input some data.

items = []
if (option=="1"):
    print "we will now enter the information for this item"
    items.append(user_input())
If that is not some school assignment consider to learning Python 3 instead of v2. The time is not going back
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#12
Oh ok so it does the same thing i have done with

item_number = raw_input("what is the item number ")
item_name = raw_input("what is the name of this item? ")
item_price = raw_input("how much does this item cost? ")

but with the function i can use it anywhere else i need to instead of typing all this stuff again
Reply
#13
That is the functions purpose.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with writing monitored data to mysql upon change of one particular variable donottrackmymetadata 3 183 Yesterday, 09:55 PM
Last Post: deanhystad
  Commas issue in variable ddahlman 6 387 Apr-05-2024, 03:45 PM
Last Post: deanhystad
  Variable Explorer in spyder driesdep 1 199 Apr-02-2024, 06:50 AM
Last Post: paul18fr
  Mediapipe. Not picking up second variable stevolution2024 1 173 Mar-31-2024, 05:56 PM
Last Post: stevolution2024
Question Variable not defined even though it is CoderMerv 3 251 Mar-28-2024, 02:13 PM
Last Post: Larz60+
  optimum chess endgame with D=3 pieces doesn't give an exact moves_to_mate variable max22 1 251 Mar-21-2024, 09:31 PM
Last Post: max22
  difference between forms of input a list to function akbarza 6 1,020 Feb-21-2024, 08:02 PM
Last Post: bterwijn
  Reading and storing a line of output from pexpect child eagerissac 1 4,229 Feb-20-2024, 05:51 AM
Last Post: ayoshittu
  unbounded variable akbarza 3 491 Feb-07-2024, 03:51 PM
Last Post: deanhystad
  Variable for the value element in the index function?? Learner1 8 633 Jan-20-2024, 09:20 PM
Last Post: Learner1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020