• Register
0 votes
121 views

Problem :

I am facing below python list problem
design a program that lets the user enter the total rainfall for each of 12 months into an array
6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

In Python you can not use dictionaries so you can make a separate list for the month names as shown in below example:

months = ["jan", "feb", "mar", ... ]

Then you can use the index of the returned value in any given method to get the month name from the other list,as shown in below example:

def lowest():
    low = min(year)
    month = months[year.index(low)]
   
9 7 4
38,600 points

Related questions

1 vote
1 answer 92 views
92 views
Problem: I wrote a program that asks the user to enter the amount of a purchase and then it sums up the total bill with 15% vat and 0.07% service tax. I wrote the program in python: vat = 0.15 sales_tax = 0.075 product_price = float(input("Please enter the ... not defined I can not solve this thing. I am new in python programming language so please help me to solve this error. Thanks in advance.
asked May 6, 2020 samhaz 5k points
1 vote
1 answer 310 views
310 views
Problem: I wrote a program in python that asks the user for a number n and prints the sum of the numbers 1 to n: x = 1, addition = 0 n = int(input('Please enter a number:')) for i in range(x, n): addition = addition + i print (addition) But when ... n): TypeError: 'tuple' object cannot be interpreted as an integer Is there any thing that is missing from my code. Please help me to solve this out.
asked Jun 10, 2020 samhaz 5k points
0 votes
2 answers 103 views
0 votes
2 answers 240 views
240 views
Problem : Python Program to Calculate the Average of Numbers in a Given List
asked Oct 21, 2019 peterlaw 6.9k points
0 votes
1 answer 117 views
117 views
Problem : Facing following issue related to list in Python given that a refers to a list, write the necessary code to reverse the elements of the list.
asked Nov 16, 2019 peterlaw 6.9k points
1 vote
1 answer 42 views
42 views
Problem: I was trying to check if an element does exist in a list using a pyhton program: primary_list = [ 10, 12, 16, 6, 20, 33 ] a = input("Please enter a number to check if this exists in the list: ") print("Checking if input exists in this list : ") for ... not giving any output that is right. What should I do to fix this and how to check if an element does exist in a list. Thanks in advance.
asked May 16, 2020 samhaz 5k points
1 vote
1 answer 27 views
27 views
Problem: I have a simple and basic level question to you guy. How can I replace an element in a list python? Yeah, it might be a silly question but need to be answered badly. I am struggling with this problem for the last thirty minutes almost. But I am unable to sort out this thing. Your kind help is much needed. Thanks
asked Apr 4, 2020 Gavin 15.3k points
1 vote
1 answer 22 views
22 views
Problem: Hello Kodlogers, Myself is a high school student. I’ve started learning Python programming recently. I am wanting to replace an item in a list python. Let’s say I have a list of integers like: my_list = [10, -15, 1, 8, 0, 9, -5, 13, -1, 5] ... or 1. Negatives values with -1, positive values with 1 and leave 0 untouched. Is it doable? If doable, how? Thanks for your help, mate.
asked Apr 4, 2020 Gavin 15.3k points