Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/354.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 3.4.1中输入n个字符串_Python_Python 3.x - Fatal编程技术网

在Python 3.4.1中输入n个字符串

在Python 3.4.1中输入n个字符串,python,python-3.x,Python,Python 3.x,最初,我尝试将整数t作为输入,然后t行跟随每个包含字符串的行 伊奥费罗:读一行的时候是“伊奥夫”。你能指出我哪里做错了吗 for i in range(input()): d = input() a = list(d) b = set(a) print (len(b)) 我认为唯一的错误是您需要将range(input())转换为range(int(input()),因为simpleinput()是一个字符串,没有范围: >>> for i

最初,我尝试将整数t作为输入,然后t行跟随每个包含字符串的行 伊奥费罗:读一行的时候是“伊奥夫”。你能指出我哪里做错了吗

for i in range(input()): 
    d = input()
    a = list(d)
    b = set(a)
    print (len(b))

我认为唯一的错误是您需要将
range(input())
转换为
range(int(input())
,因为simple
input()
是一个字符串,没有范围:

>>> for i in range(int(input())):
...      d=input()
...      a=list(d)
...      b=set(a)
...      print(len(b))
... 
4
Hello
4
There
4
are
3
selective
7

首先,你的代码都在一行中。它不是在一行中。OP没有格式化它。我想你如何运行程序?与你的错误无关(Bhat在下面指出):你不需要转换为列表的中间步骤-你可以直接调用
set(d)