How to number each print output?
📁 function, Advanced Python Topics, bots
I have a function that outputs to the terminal during operation:
print(""..."")I need each new print to be numbered:
print (""[1]..."") If you just need to output it, use:
a = 987print(*str(a), sep=',')# /\\ Separator between elements# /\\ Converting number to string# /\\ Unpacking string into individual charactersIf you need to save the string '9,8,7' somewhere, then:
a = 987result = ','.join(str(a))# /\\ Converting number to string# /\\ Iterating over each character of the string# Log in to leave an answer