Guided Project 1: Explore Function Returning "None"

Mission Link: https://app.dataquest.io/m/350/guided-project%3A-profitable-app-profiles-for-the-app-store-and-google-play-markets/2/opening-and-exploring-the-data

Question:

I’m unsure why I’m seeing “None” in the code result. Does anyone have any insight why the function has returned it? Thank you in advance for your help!

Code:

#explore data function

def explore_data(dataset, start, end, rows_and_columns = False):
    dataset_slice = dataset[start:end]    
    for row in dataset_slice:
        print(row)
        print('\n') # adds a new (empty) line after each row

    if rows_and_columns:
        print('Number of rows:', len(dataset))
        print('Number of columns:', len(dataset[0]))
        

print('App Store')
print('\n')
print(explore_data(app_store_data, 0, 3, True))
print('\n')
print('Google Play')
print('\n')
print(explore_data(google_play_data, 0, 3, True))

Result:

App Store

[‘284882215’, ‘Facebook’, ‘389879808’, ‘USD’, ‘0.0’, ‘2974676’, ‘212’, ‘3.5’, ‘3.5’, ‘95.0’, ‘4+’, ‘Social Networking’, ‘37’, ‘1’, ‘29’, ‘1’]

[‘389801252’, ‘Instagram’, ‘113954816’, ‘USD’, ‘0.0’, ‘2161558’, ‘1289’, ‘4.5’, ‘4.0’, ‘10.23’, ‘12+’, ‘Photo & Video’, ‘37’, ‘0’, ‘29’, ‘1’]

[‘529479190’, ‘Clash of Clans’, ‘116476928’, ‘USD’, ‘0.0’, ‘2130805’, ‘579’, ‘4.5’, ‘4.5’, ‘9.24.12’, ‘9+’, ‘Games’, ‘38’, ‘5’, ‘18’, ‘1’]

Number of rows: 7197
Number of columns: 16
None

Google Play

[‘Photo Editor & Candy Camera & Grid & ScrapBook’, ‘ART_AND_DESIGN’, ‘4.1’, ‘159’, ‘19M’, ‘10,000+’, ‘Free’, ‘0’, ‘Everyone’, ‘Art & Design’, ‘January 7, 2018’, ‘1.0.0’, ‘4.0.3 and up’]

[‘Coloring book moana’, ‘ART_AND_DESIGN’, ‘3.9’, ‘967’, ‘14M’, ‘500,000+’, ‘Free’, ‘0’, ‘Everyone’, ‘Art & Design;Pretend Play’, ‘January 15, 2018’, ‘2.0.0’, ‘4.0.3 and up’]

[‘U Launcher Lite – FREE Live Cool Themes, Hide Apps’, ‘ART_AND_DESIGN’, ‘4.7’, ‘87510’, ‘8.7M’, ‘5,000,000+’, ‘Free’, ‘0’, ‘Everyone’, ‘Art & Design’, ‘August 1, 2018’, ‘1.2.4’, ‘4.0.3 and up’]

Number of rows: 10841
Number of columns: 13
None

In Python functions, if you don’t have a Return statement, the function returns a None.

So, if you try to use print on the function call, like you have in -

print(explore_data(app_store_data, 0, 3, True))

it prints out that None.

Since your explore_data function is only printing out certain details and not returning any value, you can simply call the function normally, without having to use print again -

explore_data(app_store_data, 0, 3, True)

The above won’t print that None.

Note: I modified your question details to properly format your code. Please try to make sure you format your code for future posts. It makes it readable.

2 Likes

Thank you very much!

1 Like