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
#1
Hey Guys,

I'm new to Python programming and am having trouble finding some information on some coding I am trying to write for fun. I have some experience with c++ programming so i understand some of the basic structure of coding, however i can't find a way to get the program I am working on to do what i need it to.

Basically i am trying to take user input and store it to a variable and store that variable to a list defined by another variable then be able to retrieve that user input by having the user enter a number so...

user inputs item_number as 75 lets say 75 is for this purpose a serial number
user inputs item_name as hat
user inputs item_price as 10.25

this would be the information for item1

so item1 = [item_number, item_name, item_price]??

then if the user chooses to list all items stored i would print item1
where the items and there info would be listed 
1: s/n 75
    hat
    10.25

formatting aside at this time I want the user to be able to reference the s/n but not actually have to enter the s/n to select the number

firstly can a variable that is defined with user input from an if statement be stored in a list as i have it here above

and if it can then is it as simple as assigning that "item1" to be printed if the user inputs say the number 1??
Reply


Messages In This Thread
Taking user input and storing that to a variable then storing that variable to a list - by jowalk - Mar-27-2017, 09:46 PM

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 266 Mar-07-2025, 05:02 AM
Last Post: surendrasamudrala
  not able to call the variable inside the if/elif function mareeswaran 3 538 Feb-09-2025, 04:27 PM
Last Post: mareeswaran
  How to revert back to a previous line from user input Sharkenn64u 2 886 Dec-28-2024, 08:02 AM
Last Post: Pedroski55
  Storing DictProxy object and modifying its nested value? haihal 3 1,017 Dec-20-2024, 04:58 AM
Last Post: deanhystad
  LLM data I/O - for storing notes Alkanet 0 337 Dec-19-2024, 09:08 AM
Last Post: Alkanet
  creating arbitrary local variable names Skaperen 9 1,796 Sep-07-2024, 12:12 AM
Last Post: Skaperen
  Variable Substitution call keys Bobbee 15 2,704 Aug-28-2024, 01:52 PM
Last Post: Bobbee
  User input with while loops chizzy101010 2 5,175 Aug-25-2024, 06:00 PM
Last Post: chizzy101010
  Storing data in readable place user_404_lost_and_found 4 1,402 Jul-22-2024, 06:14 AM
Last Post: Pedroski55
  how solve: local variable referenced before assignment ? trix 5 1,728 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