1

Very confused why the return function doesn't return my variable to the screen when I run it using pycharm. the print function works perfectly fine but I'm trying to use return when writing functions. any help appreciated. here is the code I'm trying with:

def disemvowel(string):
    message = []
    vowels = ['a', 'e', 'i', 'o', 'u']
    for letter in string:
        if letter not in vowels:
            message.append(letter)
    return message

disemvowel('laol')

if I substitute return with print it works the way I intend it to work

Once again any help appreciated

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
W R
  • 11
  • 2
  • 4
    `return` does not print to the screen. But there is a feature in the interactive interpreter (only) that prints the result of the line interpreted to the screen. – Klaus D. Oct 03 '19 at 03:26

1 Answers1

0

You just need to print the result:

print(disemvowel('laol'))

The result of an expression (i.e. the returned value in this case) isn't printed, except in an interactive session.

wjandrea
  • 28,235
  • 9
  • 60
  • 81