Description of the problem: TypeError: 'type' object is not iterable occurs when python3 passes list in the def function
My list is obtained in the following way, value_list is some elements in the obtained set, which is actually a list too.
But passing the list into a def will report an error. Because it is traversed directly with for i in value_list: in this form, an error will be reported if this form is found.
But in the function changed to
def str_join(str_list): # The input is a list, and all the elements in the set are directly spliced together and returned. l_result = "" it = iter(str_list) for l in it: l_result = l_result + l return l_result
This is not wrong.
But if you don't use the def function to pass in the list, but directly after fetching the set, directly for i in value_list: this will not report an error.