Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何为列表赋值_Python_String_List_Python 2.7_Loops - Fatal编程技术网

Python 如何为列表赋值

Python 如何为列表赋值,python,string,list,python-2.7,loops,Python,String,List,Python 2.7,Loops,十进制数字系统由十位数字组成,我们将其表示为“0123456789”。编写一个程序,将这些值赋予给定列表的元素 L = ['f','c','e','a','d','p','z','y','k','m']. 比如说 Input is fff Output is000 注意:代码不应包含“for”! 输入为“ccc” 产量为111 输入为“eeeee” 产量为22222 我想在python笔记本(python 2.7)上为这个程序编写一个代码!但我没有这样做。请帮帮我 使用函数: >>

十进制数字系统由十位数字组成,我们将其表示为“0123456789”。编写一个程序,将这些值赋予给定列表的元素

L = ['f','c','e','a','d','p','z','y','k','m'].
比如说

Input is fff
Output is000
注意:代码不应包含“for”! 输入为“ccc” 产量为111 输入为“eeeee” 产量为22222

我想在python笔记本(python 2.7)上为这个程序编写一个代码!但我没有这样做。请帮帮我

使用函数:

>>> x = 'fff'
>>> print ''.join(str(L.index(el)) for el in x)
000

你能展示一下你试过的代码吗?另外,请明确指出您的代码给您带来的问题。我没有在这台笔记本电脑的代码!