Hi,
I'm trying to learn python programming. I have a question.
This is my script:
Declare my variables
strName = '' # The name of the item
strValue = '' # The estimated value of the item
srChoice = '' # A choice by the user
lstRow = []
lstTable=[]
# Step 1: Display a menu of choices to the user
while (True): # Step 1
print("""
Menu of Options
1) Add Data to List
2) Display Current Data
3) Exit and Save to File
""")
strChoice = str(input("which option would you like to perform? [1 to 3]: "))
if strChoice == '1':
print("Type in a 'Name' and Value fo Household Items")
strName = str(input(" Enter a Name: "))
strValue = str(input(" Enter a Value: "))
lstRow = [strName, strValue]
lstTable += lstRow
elif strChoice == '2':
print('Your Current Data is')
for row in lstTable:
print('', row[0], ',', row[1])
elif strChoice == '3':
print('Option 3')
break #Exits out Loop
else:
print('Please only choose 1, 2, or 3 !')
When I ran the program:
which option would you like to perform? [1 to 3]: 1
Type in a 'Name' and Value fo Household Items
Enter a Name: lmap
Enter a Value: 30
Menu of Options
1) Add Data to List
2) Display Current Data
3) Exit and Save to File
which option would you like to perform? [1 to 3]: 2
Your Current Data is
l , m
3 , 0
I believe it should say lmap, 30. Why is the print statement only giving me that type of output?
Thank you
I'm trying to learn python programming. I have a question.
This is my script:
Declare my variables
strName = '' # The name of the item
strValue = '' # The estimated value of the item
srChoice = '' # A choice by the user
lstRow = []
lstTable=[]
# Step 1: Display a menu of choices to the user
while (True): # Step 1
print("""
Menu of Options
1) Add Data to List
2) Display Current Data
3) Exit and Save to File
""")
strChoice = str(input("which option would you like to perform? [1 to 3]: "))
if strChoice == '1':
print("Type in a 'Name' and Value fo Household Items")
strName = str(input(" Enter a Name: "))
strValue = str(input(" Enter a Value: "))
lstRow = [strName, strValue]
lstTable += lstRow
elif strChoice == '2':
print('Your Current Data is')
for row in lstTable:
print('', row[0], ',', row[1])
elif strChoice == '3':
print('Option 3')
break #Exits out Loop
else:
print('Please only choose 1, 2, or 3 !')
When I ran the program:
which option would you like to perform? [1 to 3]: 1
Type in a 'Name' and Value fo Household Items
Enter a Name: lmap
Enter a Value: 30
Menu of Options
1) Add Data to List
2) Display Current Data
3) Exit and Save to File
which option would you like to perform? [1 to 3]: 2
Your Current Data is
l , m
3 , 0
I believe it should say lmap, 30. Why is the print statement only giving me that type of output?
Thank you