how to display digits in a number printed, separated by two spaces? in python
Solution 1:
One way would be to convert the integer to a string and then use .join() to join the characters of a string together with specified characters in between.
def print_value(number):
print(' '.join(str(number))) # converts number to a string and inserts two spaces between each character (' ')
This works because .join() is used to join together the elements of a list into a string. Strings can also be interpreted as a list of individual characters ('hi' = ['h', 'i']), so using .join() on them works as well.