在Python上不带括号的情况下打印列表

鲍比·鲍勃

我想知道是否有人可以提供帮助,所以当用户输入“英语”,“西班牙语”或“两者”时,它会打印出没有括号和语音标记的列表,我只需要逗号。我尝试环顾四周,但是没有任何代码有效。任何帮助将非常感激。

english_list = ["fire","apple","morning","river"]
spanish_list = ["fuego","manzana","manana","rio"]
english_to_spanish = dict(zip(english_list, spanish_list))
spanish_to_english = dict(zip(spanish_list, english_list))


def viewwordlist():
    if word == 'show':
        wordlist = input("""
    Type 'English' to view the English word list
    Type 'Spanish' to view the Spanish word list
    Type 'Both' to view both of the word lists
    """).lower().strip()
        if wordlist == 'english':
            print("Here is the current English word list:")
            print(english_list)
        elif wordlist == 'spanish':
            print("Here is the current Spanish word list:")
            print(spanish_list)
        elif wordlist == 'both':
            print("Here is both the current English and Spanish word list:")
            print("Current English list:")
            print(english_list)
            print("Current Spanish list:")
            print(spanish_list)
        else:
            print("Sorry, that wasn't a option. If you need some assistance please enter 'help'")
科里·克莱默(Cory Kramer)
english_list = ["fire","apple","morning","river"]

如果您只是print一个listPython,它将使用单引号和方括号,因为这是它使用的语法。

>>> print english_list
['fire', 'apple', 'morning', 'river']

如果只想用逗号分隔单词,则可以使用快速join表达

>>> print ', '.join(english_list)
fire, apple, morning, river

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在不带括号和逗号的情况下打印列表python

寻找json键以在python中不带括号的情况下打印其内容

如何在python中不带括号的情况下打印变量

如何在没有括号的情况下打印列表?

在R中不带方括号的情况下打印结果

为什么在带和不带括号的情况下打印时会给出__str __()和__repr __()

如何在不带括号的情况下将查询集作为单独行的列表返回

打印不带括号和逗号的列表(python)

打印不带括号python的元组列表

React默认情况下会调用useState而不带括号

如何在python 3中不带空格的情况下打印?

单行不带括号的打印列表

单行不带括号的打印列表

Pandas 按位过滤在带括号和不带括号的情况下给出不同的结果

如何在Python中打印不带括号的元组列表

Python:如何打印不带引号和方括号的列表

在不带括号的列表中打印多个列表

在addEventListener中如何在不带括号的情况下使用该函数?

如何在不带引号和括号的情况下将整数值写入文件

如何在不带括号的情况下将数组写入CVS?

我可以在不带Java括号的情况下访问Scala对象的val吗?

(Python)在没有括号的情况下将列表添加到另一个列表

在 Dart 中打印不带括号的列表

不用于打印的不带括号的列表或元组

在不破坏括号格式的情况下删除列表中的最后一个元素(括号)

如何在不带“可选”的情况下从plist打印字符串?

如何在不带引号的情况下打印字典的字符串值?

如何在C中不带printf的情况下打印LLONG_MIN?

如何在没有方括号的情况下打印