I need to use my function as a variable but when I tried to use it with formatted string it print the variable ID, but when I use it like this -->
dot = efdot
dot()
It prints function. Here is my code I summarized it.
code:
import time
def efdot():
bar = "⦾⦿"
index = 0
while True:
print(bar[index % len(bar)], end="\r")
index += 1
time.sleep(0.5)
dot = efdot
var = input(f"{dot}Hello World{dot}")
output:
<function efdot at 0x0000016EDCEF3E20>Hello World<function efdot at 0x0000016EDCEF3E20>
You need to call your function with the parentheses:
dot()But because your function never ends with that infinite loop, it won't print the rest of the string.
Summary: