I am attempting an exercise where the user inputs a positive integer and the output should be a seven-segment display conversion.
Each digit is converted using hashed symbols so whatever digit is inputted, each of those individual numbers are converted to hashed symbols and added to empty string.
Here is my code:
zero = '###\n# #\n# #\n# #\n###\n\n'
one = '#\n#\n#\n#\n#\n\n'
two = '###\n  #\n###\n#  \n###\n\n'
three = '###\n  #\n###\n  #\n###\n\n'
four = '# #\n# #\n###\n  #\n  #\n\n'
five = '###\n#  \n###\n  #\n###\n\n'
six = '###\n#  \n###\n# #\n###\n\n'
seven = '###\n  #\n  #\n  #\n  #\n\n'
eight = '###\n# #\n###\n# #\n###\n\n'
nine = '###\n# #\n###\n  #\n###\n\n'
    def seven_segment_display(digit):
      if digit >= 0:
        digit = str(digit)
        digit_list = list(digit)
        new_digit = ''
        for i in range(len(digit_list)):
            if digit_list[i] == '0':
                new_digit += zero
            if digit_list[i] == '1':
                new_digit += one
            if digit_list[i] == '2':
                new_digit += two
            if digit_list[i] == '3':
                new_digit += three
            if digit_list[i] == '4':
                new_digit += four
            if digit_list[i] == '5':
                new_digit += five
            if digit_list[i] == '6':
                new_digit += six
            if digit_list[i] == '7':
                new_digit += seven
            if digit_list[i] == '8':
                new_digit += eight
            if digit_list[i] == '9':
                new_digit += nine
    return new_digit
print(seven_segment_display(123))
When I run the code, it outputs converted digits vertically as opposed to horizontally.
I am trying to output each of the converted digits on the same line.
I tried stripping newline but that still didn't print out each digit horizontally.
Any ideas on how to do this? I'm new to Python so any help would be appreciated!
 
    