D
D
Dmitry2016-12-09 18:15:57
Python
Dmitry, 2016-12-09 18:15:57

Can't parse a solution to a problem in Python 3?

please help with the elementary problem below:
zero=[" *** ", "* *", "* *", "* *", "* *", "* *", " *** "]
one= [" *", " **", "* *", " *", " *", " *", " *"]
two=[" ***** ", "* *", "* * ", " * ", " * ", " * ", "*******"]
three=[" ***** ", "* *", " * ", " *** ", " * ", "* *", " ***** "]
four=[" *", " * *", " * *", " * *", " ******", " * ", "*"]
five=["*******", "* *", "* ", "****** ", " *", "* *", "****** "]
six=["* ", "* ", "* ", "****** ", "* *", "* *", " ***** "]
seven=["** *****", "*", "*", "*", "*", "*", "*"]] seven=["*******", " *", " * ", " * ", " * ", "* ", "* "]] seven=["*******", " *", " * ", " * ", " * ", "* ", "* "]
eight=[" ***** ", "* *", "* *", " *** ", "* *", "* *", " ***** "]
nine=[" * **** ", "* *", "* *", " ******", " *", " *", " *"]
Digits=[Zero, One, Two, Three, Four, Five, Six, Seven, Eight, Nine]
try:
****digits = sys.argv[1]
****row = 0
****while row < 7:
********line = ""
**********column = 0
********while column < len(digits):
************number = int(digits[column])
************digit = Digits[number]
************line += digit[row] + " "
************column += 1
********print(line)
********row += 1
except IndexError:
****print(" usage: bigdigits.py")
except ValueError as err:
****print(err, "in", digits)
wrote off everything from the textbook, but I can't print the numbers

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
asd111, 2016-12-09
@ipatov_dn

Everything is working. If you do not know how to pass arguments at startup, then do raw_input.

import sys

from pip._vendor.distlib.compat import raw_input

Zero = ["  ***  ",
        " *   * ",
        "*     *",
        "*     *",
        "*     *",
        " *   * ",
        "  ***  "]
One = [" * ", "** ", " * ", " * ", " * ", " * ", "***"]
Two = [" *** ", "*   *", "*  * ", "  *  ", " *   ", "*    ", "*****"]
Three = [" *** ", "*   *", "    *", "  ** ", "    *", "*   *", " *** "]
Four = ["   *  ", "  **  ", " * *  ", "*  *  ", "******", "   *  ",
        "   *  "]
Five = ["*****", "*    ", "*    ", " *** ", "    *", "*   *", " *** "]
Six = [" *** ", "*    ", "*    ", "**** ", "*   *", "*   *", " *** "]
Seven = ["*****", "    *", "   * ", "  *  ", " *   ", "*    ", "*    "]
Eight = [" *** ", "*   *", "*   *", " *** ", "*   *", "*   *", " *** "]
Nine = [" ****", "*   *", "*   *", " ****", "    *", "    *", "    *"]

Digits = [Zero, One, Two, Three, Four, Five, Six, Seven, Eight, Nine]

try:
    digits = raw_input("Введите число\n") # Заменяем передачу аргумента при запуске на введение пользователем
    row = 0
    while row < 7:
        line = ""
        column = 0
        while column < len(digits):
            number = int(digits[column])
            digit = Digits[number]
            line += digit[row] + " "
            column += 1
        print(line)
        row += 1
except IndexError:
    print("usage: bigdigits.py <number>")
except ValueError as err:
    print(err, "in", digits)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question