如何使用python打印用户输出的句子

如何使用python打印用户输出的句子,python,python-3.x,Python,Python 3.x,我有一本python字典,如下所示: dict1 = {'a':1, 'b':2, 'c':3} 到目前为止,我已经在Python 3中运行了以下代码: for key, value in dict1.items() : print (key* value,end='') 这给了我输出:cccbba 我的问题是如何打印出来- Your answer : cccba. 大概是这样的: dict1 = {'a':1, 'b':2, 'c':3} print ("Your ans

我有一本python字典,如下所示:

dict1 = {'a':1, 'b':2, 'c':3}
到目前为止,我已经在Python 3中运行了以下代码:

for key, value in dict1.items() :   
    print (key* value,end='')
这给了我输出:cccbba

我的问题是如何打印出来-

Your answer : cccba.
大概是这样的:

dict1 = {'a':1, 'b':2, 'c':3}

print ("Your answer : ",end='')

for key, value in dict1.items() :   
    print (key* value,end='')

你应该认真对待以下问题:

>>> print("Your answer: {0}".format("".join([k * v for k, v 
                                             in dict1.items()])))
Your answer: acccbb