简体   繁体   中英

How to print name using python

I need to write a code for printing my name as below by taking the user input for a name. I need to use for and if statements.

Here is an AZ list of the words. I know how to do the input code but I am unsure of how to actually loop it using 'for' and 'if' statements. I have tried to google search for help but nothing has helped.

# print A to Z in python for Q7
print("..######..\n..#....#..\n..######..\n..#....#..\n..#....#..\n\n")

print("..######..\n..#....#..\n..#####...\n..#....#..\n..######..\n\n")
print("..######..\n..#.......\n..#.......\n..#.......\n..######..\n\n")

print("..#####...\n..#....#..\n..#....#..\n..#....#..\n..#####...\n\n")
print("..######..\n..#.......\n..#####...\n..#.......\n..######..\n\n")

print("..######..\n..#.......\n..#####...\n..#.......\n..#.......\n\n")

print("..######..\n..#.......\n..#####...\n..#....#..\n..#####...\n\n")

print("..#....#..\n..#....#..\n..######..\n..#....#..\n..#....#..\n\n")

print("..######..\n....##....\n....##....\n....##....\n..######..\n\n")

print("..######..\n....##....\n....##....\n..#.##....\n..####....\n\n")

print("..#...#...\n..#..#....\n..##......\n..#..#....\n..#...#...\n\n")

print("..#.......\n..#.......\n..#.......\n..#.......\n..######..\n\n")

print("..#....#..\n..##..##..\n..#.##.#..\n..#....#..\n..#....#..\n\n")

print("..#....#..\n..##...#..\n..#.#..#..\n..#..#.#..\n..#...##..\n\n")

print("..######..\n..#....#..\n..#....#..\n..#....#..\n..######..\n\n")

print("..######..\n..#....#..\n..######..\n..#.......\n..#.......\n\n")

print("..######..\n..#....#..\n..#.#..#..\n..#..#.#..\n..######..\n\n")

print("..######..\n..#....#..\n..#.##...\n..#...#...\n..#....#..\n\n")

print("..######..\n..#.......\n..######..\n.......#..\n..######..\n\n")

print("..######..\n....##....\n....##....\n....##....\n....##....\n\n")

print("..#....#..\n..#....#..\n..#....#..\n..#....#..\n..######..\n\n")

print("..#....#..\n..#....#..\n..#....#..\n...#..#...\n....##....\n\n")

print("..#....#..\n..#....#..\n..#.##.#..\n..##..##..\n..#....#..\n\n")

print("..#....#..\n...#..#...\n....##....\n...#..#...\n..#....#..\n\n")

print("..#....#..\n...#..#...\n....##....\n....##....\n....##....\n\n")

print("..######..\n......#...\n.....#....\n....#.....\n..######..\n\n")

print("..........\n..........\n..........\n..........\n\n")

print("----..----\n\n")

This is what I have so far (really not much):

name=input("Enter a name: ")

For example, if your name was seymour, it would look like this (the code would be vertical, I understand that it does print horizontal on this website):

seymour
..######..
..#.......
..######..
.......#..
..######..


..######..
..#.......
..#####...
..#.......
..######..


..#....#..
...#..#...
....##....
....##....
....##....


..#....#..
..##..##..
..#.##.#..
..#....#..
..#....#..


..######..
..#....#..
..#....#..
..#....#..
..######..


..#....#..
..#....#..
..#....#..
..#....#..
..######..


..######..
..#....#..
..#.##...
..#...#...
..#....#..

instead of printing them create a dict ... and just uppercase the input and look it up

d = {
  # A B C ...
  "G": "..######..\n..#.......\n..#..###..\n..#....#..\n..######..\n\n",
  "H": "..#....#..\n..#....#..\n..######..\n..#....#..\n..#....#..\n\n",
  "I": "..######..\n....##....\n....##....\n....##....\n..######..\n\n",
  "J": "..######..\n....##....\n....##....\n..#.##....\n..####....\n\n",
  "K": "..#...#...\n..#..#....\n..##......\n..#..#....\n..#...#...\n\n"
  # L M N
  # convert the rest of the print statements to dict entries
# print("..#.......\n..#.......\n..#.......\n..#.......\n..######..\n\n")
# print("..#....#..\n..##..##..\n..#.##.#..\n..#....#..\n..#....#..\n\n")

}
def print_word(word):
  for letter in word.upper():
     print(d[letter])

print_word("jIg")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM