1
def call_10(func):
    for i in range(10):
        func()
def print_hello():
    return 'hello'
call_10(print_hello)

but if

def call_10(func):
    for i in range(10):
        func()
def print_hello():
    print('hello')
call_10(print_hello)

it works! I want ask about difference

ScottC
  • 3,941
  • 1
  • 6
  • 20
고준호
  • 11
  • 2
  • `print` will print the value to the terminal, whereas return sends the value back but in your code it does not do anything with the returned value. In the first set of code you would have to call print(func()) to make them equivalent. – ScottC Jan 15 '23 at 11:41

0 Answers0