I'm not getting the output in this program

Screen Link:

My Code:

apple_apps=[]
opened_file_1=open('AppleStore.csv')
apple_apps.append(opened_file_1)
apple_header=apple_apps[0]
apple_apps=apple_apps[1:]
opened_file_2=open('googleplaystore.csv')
google_apps=[]
google_apps.append(opened_file_2)
google_header=google_apps[0]
google_apps=google_apps[1:]
def explore_data(dataset,start,end,rows_and_cols=False):
    dataset_slice=dataset[start:end]
    for row in dataset_slice:
        print(row)
        print('\n')
        if rows_and_cols:
            print('No.of rows:',len(dataset))
            print('No.of columns',len(dataset[0]))
apple=explore_data(apple_apps,0,3,False)
google=explore_data(google_apps,0,3,False)

What I expected to happen:
I just wanted to get some output

What actually happened:

There is no output i mean it just run but no output displayed 
1 Like

Hello @sivaramkrishnanethet, there is no output because your function is returning None. If you want your function to print the output do not assign it to a variable when calling it.

instead of above, just call the function without assigning it to a variable:

explore_data(apple_apps,0,3,False)
explore_data(google_apps,0,3,False)
1 Like

Hello @sivaramkrishnanethet,

You are reading file wrongly.

It should be

from csv import reader
apple_apps = list(reader(opened_file_1))

And for another file same

google_apps = list(reader(opened_file_2))
2 Likes

Hello @info.victoromondi,

The assignment here is of course unnecessary. But this does not affect the print statements that we are doing in the function. It must be printed if we have print statement in the function regardless of whatever return type of the function.

1 Like