Write a program that prompts the user for an amount (whole number). The program
ID: 3548025 • Letter: W
Question
Write a program that prompts the user for an amount (whole number). The program should then increase the values of the first column by that amount and store the updated values in the second column of the 2D list provided. It then should call a function that displays the contents of the 2D list row-by-row. Use forloops in your solution. Write a function to display the contents of the 2D list. Name the program increase_amt.py.
here is the start file
def main():
values = [[10,0], [13, 0], [36, 0], [74,0], [22,0]]
input('press enter to continue')
# Call the main function
main()
Explanation / Answer
Here is the working code:
def display(val):
for i in val:
print i[1]
values = [[10,0], [13, 0], [36, 0], [74,0], [22,0]]
print "Enter a number"
val=int(raw_input())
for i in values:
i[1]=i[0]+val
display(values)
Here is the input and output
Input:
Please rate my efforts :)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.