'how to fix printing memory address in python [closed]

I've been trying to fix this problem with my code, where the memory address is printed in the console. I suspect it's something to do with iterating through the "wordlist" list.

#wordlist is actually around 500 words long.
wordlist = ['games', 'happy', 'gxems', 'hpapy']
letters = "abcdefghijklmnopqrstuvwxyz"
def get_possible_letters(word):
  possible_letters = letters
  count = 0
  for i in word:
    if i in letters:
      possible_letters.remove(i)
  return possible_letters

def get_most_information():
  score = 0
  top_score = 27
  for i in wordlist:
    score = len(letters) - len(get_possible_letters(i))
    if score < top_score:
      top_score = score
  return top_score

print(get_most_information) 


Solution 1:[1]

The last statement should be

print(get_most_information())

instead of

print(get_most_information)

The latter merely prints the location of the function in memory instead of printing the function's output.

Solution 2:[2]

You need to have () on functions to call the function:

# Function must have () on end
print(get_most_information())

I've commented some recommended edits below:

# wordlist is actually around 500 words long.
wordlist = ['games', 'happy', 'gxems', 'hpapy']
# Letters must be global, or passed as arg to be used in another function
letters = "abcdefghijklmnopqrstuvwxyz"


def get_possible_letters(word):
    possible_letters = letters
    count = 0
    for i in word:
        if i in letters:
            # Replace, not remove on strings
            possible_letters.replace(i, "")
    return possible_letters


def get_most_information():
    score = 0
    top_score = 27
    for i in wordlist:
        score = len(letters) - len(get_possible_letters(i))
        if score < top_score:
            top_score = score
    return top_score


# Function must have () on end
print(get_most_information())
# Outputs 0

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RevoGen
Solution 2 Freddy Mcloughlan