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
  I trying to automate the Variable Logon button using the python code but I couldn't surendrasamudrala 0 253 Mar-07-2025, 05:02 AM
Last Post: surendrasamudrala
  not able to call the variable inside the if/elif function mareeswaran 3 497 Feb-09-2025, 04:27 PM
Last Post: mareeswaran
  How to revert back to a previous line from user input Sharkenn64u 2 796 Dec-28-2024, 08:02 AM
Last Post: Pedroski55
  Storing DictProxy object and modifying its nested value? haihal 3 936 Dec-20-2024, 04:58 AM
Last Post: deanhystad
  LLM data I/O - for storing notes Alkanet 0 317 Dec-19-2024, 09:08 AM
Last Post: Alkanet
  creating arbitrary local variable names Skaperen 9 1,751 Sep-07-2024, 12:12 AM
Last Post: Skaperen
  Variable Substitution call keys Bobbee 15 2,572 Aug-28-2024, 01:52 PM
Last Post: Bobbee
  User input with while loops chizzy101010 2 4,658 Aug-25-2024, 06:00 PM
Last Post: chizzy101010
  Storing data in readable place user_404_lost_and_found 4 1,375 Jul-22-2024, 06:14 AM
Last Post: Pedroski55
  how solve: local variable referenced before assignment ? trix 5 1,654 Jun-15-2024, 07:15 PM
Last Post: trix

Forum Jump:

User Panel Messages

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