So, I'm thinking of creating a 2D array where row represents city names (in integers of course) and column representing temperature.
days = int(input("Enter days: "))
city = int(input("Enter city: "))
array = [[0]* days]*city
i = 0
printing the array with input:
days = 3
city = 3
gives me something like:
[[0,0,0],[0,0,0],[0,0,0]]
but the problem I'm having now is, how to insert values into the array?
when i was working on 1D array, i used:
while i<days:
array[i] = int(input("temperature: "))
i+=1
which inserts the temperature into the array.
array = [1,2,3]
but now that it's 2D, I can't seem to figure it out. The rows now represent the city and the column represents the temperature. I want to have something like.
[[1,2,3],[4,5,6],[7,8,9]]
How would I modify my while loop to implement 2D arrays?