-2

I am very new at python. I am wondering of the easiest way or alternative to defining a function as a string, and then printing said string in another print line, such as demonstrated here:

def world():
    print("World!")

print("Hello " + world())

I am sure that this is an easy fix/search, but I cannot seem to find what I am searching for. Thank you!

TG Imagine
  • 13
  • 2
  • 3
    What are you trying to do? Do you mean like [`return 'World!'`](https://stackoverflow.com/a/750154/15497888) from [How is returning the output of a function different from printing it?](https://stackoverflow.com/q/750136/15497888) – Henry Ecker Sep 22 '21 at 18:37
  • So, "defining a function as a string," doesn't make sense. Take a step back, and try to explain what you are trying to accomplish. – juanpa.arrivillaga Sep 22 '21 at 18:40

1 Answers1

0

I'm not sure what you are trying to accomplish here. But the answer you are looking for is,

def world():
    return ("World!")

print("Hello " + world())