判断参数是否为字符串,可迭代对象

函数 main() 接收两个参数,
其中 iterable 预期为包含若干字符串的可迭代对象,sep 预期为字符串。
如果参数sep不是字符串就返回字符串'参数sep必须是字符串',
如果参数iterable不是可迭代对象就返回字符串'参数iterable必须为可迭代对象',
如果参数iterable是可迭代对象但其中有不是字符串的元素就返回字符串'参数iterable中所有元素都必须为字符串'。
如果所有参数都符合要求就返回使用sep作为连接符对iterable中所有字符串进行连接之后的字符串。
例如,main(map(str,range(5)),',')返回‘0,1,2,3,4’。
返回不能有多余的内容,不能引用外部包。

考点:字符串
感觉是要使用map和str结合使用

def main(iterable, sep=''):
    for i in sep:
        if sep not  is str:
            return '参数sep必须是字符串'
    for j in iterable:
        if iterable not iterable:        #???
            return '参数iterable必须为可迭代对象'
        elif str in iterable:        #其中有不是字符串的元素
            return '参数iterable中所有元素都必须为字符串'
        else:
            return main(map(str,range(iterable)),',')
'''
答题错误!您的代码执行结果为:
  File xxx.py, line 3
    if sep not is str:
               ^
SyntaxError: invalid syntax
'''

报错那句改成 if type(sep)!=str:

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^