python函数中使用for循环
1、在for循环中使用函数需要更长的执行时间,因为每次迭代都会调用该函数。
2、如果for循环是在函数内部实现的,那么该函数只会被调用一次。
实例
#创建一个函数,其中for循环在函数内部
defforinfunction(listofstrings):
forxinlistofstrings:
newstring=x.capitalize()
outputstring=x+""+newstring
print(outputstring)
以上内容为大家介绍了python培训之函数中使用for循环,希望对大家有所帮助,如果想要了解更多Python相关知识,请关注IT培训机构:千锋教育。