python 去掉变量中的引号和空格

k5ifujac  于 2023-01-16  发布在  Python
关注(0)|答案(1)|浏览(109)

我想创建一个变量[Word],它包含字母列表中的一个单词,但不包括任何括号、空格或逗号。
这是我已经到了:

Letters = ["u", "i", "p","a","o","g", "h","j","k","l","z","x","v","b"]

FirstLetter = -1
SecondLetter = 'o'
ThirdLetter = 'a'
FourthLetter = 'l'
Endletter = 0
while FirstLetter < 13:
    FirstLetter = FirstLetter +1
    Word = (Letters[FirstLetter], SecondLetter,ThirdLetter,FourthLetter,Letters[Endletter])
    print(Word)

第一行的输出为:

('u', 'o', 'a', 'l', 'u')

我想要:

uoalu

对不起,如果这是已经回答了我已经尝试了堆的建议,但不能得到它

mkshixfv

mkshixfv1#

如果要将一个字符串连接为单个字符串,则应使用join()

Word = "".join((
   Letters[FirstLetter], 
   SecondLetter,
   ThirdLetter,
   FourthLetter,
   Letters[Endletter],
 ))

相关问题