-1

I tried to call my function here and it returns function get_song_input at 0x7ff9869ee050 whats wrong with my code? I put it in python visualizer it worked out fine.

Album = namedtuple('Album', 'id artist title year songs')  
Song = namedtuple('Song', 'track title length play_count')  


def get_song_input():
    """Prompt user input."""
    songtrack = input('Enter the song\'s track:\n')
    songtitle = input('Enter the song\'s title:\n')
    songlength = input('Enter the song\'s length:\n')
    songplaycount = input('Enter the song\'s play_count:\n')
    song_info = Song(songtrack, songtitle, songlength, songplaycount)
    return song_info

print(get_song_input)

output:
<function get_song_input at 0x7ff9869ee050>
Alex Hu
  • 37
  • 7

2 Answers2

-1

As others have stated, you need the brackets, i.e.:

print(get_song_input())
jtlz2
  • 7,700
  • 9
  • 64
  • 114
-1

The function definition does not execute the function body; this gets executed only when the function is called.

To call a function, use the function name followed by parenthesis:

def my_function():
  print("Hello from a function")

my_function()
ravi malhotra
  • 703
  • 5
  • 14