# I ned some help regarding min and max

My Code:

``````opened_file = open('AppleStore.csv')

data_sizes=[]
for i in apps_data[1:]:
size=float(i)
data_sizes.append(size)
# min_size=min(data_sizes)
# max_size=max(data_sizes)

for i in data_sizes:
base_value= data_sizes
if i<base_value:
base_value=i
min_size=base_value
for i in data_sizes:
base_value_1= data_sizes
if i>base_value_1:
base_value_1=i
max_size=base_value_1
print(min_size)
print(max_size)
``````

What I expected to happen:
min_size = 589824.0
max_size = 4025969664.0

What actually happened:

``````51174400.0
389879808.0
``````

I am just curious how is my code wrong, i’ll been on this for the past 30 mins, and i can’t understand why. Could someone aid me in finding the right answer?

You need to loop `app_data[1:]`, then append `size`, which is in the third column to `data_sizes`.

This code is unnecessary .

Comment out this code. This is how I solved.

``````opened_file = open('AppleStore.csv')

data_sizes = []

for app_data in apps_data[1:]:
size = float(app_data)
data_sizes.append(size)

min_size = min(data_sizes)
print(min_size)

max_size = max(data_sizes)
print(max_size)

``````
1 Like

Thank you! What if i just wanted to use the method whereby i could - Assign first element as a minimum, and find the min and max from there on?

How can i do so? I wanted to know if i can find max and min using such a method.

Thank you!

If I understand you, you want to assign the minimum and maximum values to different variables right?

From what @info.victoromondi has explained, you can take it a step further by simply assigning a variable to the min and max values.

``````data_sizes = []

for app_data in apps_data[1:]:
size = float(app_data)
data_sizes.append(size)

min_size = min(data_sizes)
max_size = max(data_sizes)

base_value = min(data_sizes)
base_value_1 = max(data_sizes)``````