[英]Input from user is an list I made. Now how do I read it?
Basicly I've been trying to make this word generator, which displays your input in a big font in the console. 基本上,我一直在尝试制作此词生成器,该词生成器在控制台中以大字体显示您的输入。 I'm trying to take the user's input, then put each char individually in a list. 我试图接受用户的输入,然后将每个字符分别放入列表中。 So now the first item in the list is 'a' for example (with the input being 'apple' for example). 因此,现在列表中的第一项是例如“ a”(例如输入是“ apple”)。 Now there's a list I made called a. 现在有一个我创建的列表。 I want to print that list by the user's input (a). 我想通过用户输入(a)打印该列表。 How do I do so? 我该怎么做? This is my code: 这是我的代码:
a = ["@@@@@",
("@ @"),
("@ @"),
("@@@@@"),
("@ @"),
("@ @"),
("@ @")]
b = ["@@@@ ",
("@ @"),
("@ @"),
("@@@@ "),
("@ @"),
("@ @"),
("@@@@ ")]
c = ["@@@@@",
("@ "),
("@ "),
("@ "),
("@ "),
("@ "),
("@@@@@")]
d = ["@@@@ ",
("@ @"),
("@ @"),
("@ @"),
("@ @"),
("@ @"),
("@@@@ ")]
e = ["@@@@@",
("@ "),
("@ "),
("@@@@@"),
("@ "),
("@ "),
("@@@@@")]
f = ["@@@@@",
("@ "),
("@ "),
("@@@@@"),
("@ "),
("@ "),
("@ ")]
g = ["@@@@@",
("@ "),
("@ "),
("@ @@@"),
("@ @"),
("@ @"),
("@@@@@")]
h = ["@ @",
("@ @"),
("@ @"),
("@@@@@"),
("@ @"),
("@ @"),
("@ @")]
i = ["@@@@@",
(" @ "),
(" @ "),
(" @ "),
(" @ "),
(" @ "),
("@@@@@")]
j = [" @",
(" @"),
(" @"),
(" @"),
(" @"),
("@ @"),
(" @@@ ")]
k = ["@ @",
("@ @ "),
("@ @ "),
("@@ "),
("@ @ "),
("@ @ "),
("@ @")]
l = ["@ ",
("@ "),
("@ "),
("@ "),
("@ "),
("@ "),
("@@@@@")]
m = ["@ @",
("@@ @@"),
("@ @ @"),
("@ @ @"),
("@ @"),
("@ @"),
("@ @")]
word = []
input_word = input("Which word would you like to display?")
for i in input_word:
word.append(i)
Create a dictionary that maps each letter to the corresponding list: 创建一个字典,将每个字母映射到相应的列表:
letter_map = {'a': a, 'b': b, 'c': c, ...}
in = input("What letter?")
print(letter_map[in[0]])
word
contains the word word
包含单词
letters = {'a': ["@@@@@", "@ @", "@ @", "@@@@@", "@ @", "@ @", "@ @"], ...}
使其成为一个以字母为键且值在一个数组中的字典: letters = {'a': ["@@@@@", "@ @", "@ @", "@@@@@", "@ @", "@ @", "@ @"], ...}
range(7)
using for
: for row in range(7):
使用for
:遍历range(7)
for row in range(7):
使用range(7)
遍历数组中的项数for row in range(7):
for letter in word:
遍历单词字母,获取映射的符号: for letter in word:
outword += " " + letters[letter][row]
加入空格: outword += " " + letters[letter][row]
That should get you started. 那应该让您开始。 Feel free to try and post your results. 随时尝试发布您的结果。 We can help you once you have some code. 一旦您有了一些代码,我们可以为您提供帮助。
print('\\n'.join([' '.join([{'a': ["@@@@@", "@ @", "@ @", "@@@@@", "@ @", "@ @", "@ @"] , 'b': ["@@@@ ", "@ @", "@ @", "@@@@ ", "@ @", "@ @", "@@@@ "] , 'c': ["@@@@@", "@ ", "@ ", "@ ", "@ ", "@ ", "@@@@@"] , 'd': ["@@@@ ", "@ @", "@ @", "@ @", "@ @", "@ @", "@@@@ "] , 'e': ["@@@@@", "@ ", "@ ", "@@@@@", "@ ", "@ ", "@@@@@"] , 'f': ["@@@@@", "@ ", "@ ", "@@@@@", "@ ", "@ ", "@ "] , 'g': ["@@@@@", "@ ", "@ ", "@ @@@", "@ @", "@ @", "@@@@@"] , 'h': ["@ @", "@ @", "@ @", "@@@@@", "@ @", "@ @", "@ @"] , 'i': ["@@@@@", " @ ", " @ ", " @ ", " @ ", " @ ", "@@@@@"] , 'j': [" @", " @", " @", " @", " @", "@ @", " @@@ "] , 'k': ["@ @", "@ @ ", "@ @ ", "@@ ", "@ @ ", "@ @ ", "@ @"] , 'l': ["@ ", "@ ", "@ ", "@ ", "@ ", "@ ", "@@@@@"] , 'm': ["@ @", "@@ @@", "@ @ @", "@ @ @", "@ @", "@ @", "@ @"]}[l][i] for l in "abcdefghijklm"]) for i in range(7)]))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.