Skip to content

Tag: function

List and use the variables defined inside my own function

Suppose that I have a function like this one: Now can I use the a, bvariables? Even if foo() is not returning them like this? I know this is easy to do if foo was a class, but it’s not. Answer Even though you are saying you have a function, not a class, python is able to transcend those differences

I get a IndexError: list index out of range Error

I´m having some troubles on my code, that implements a function that verifies the lenght of a string and return that string with or without spaces. If String b >= 15 return b If strinf < 15 return “number os spaces until len(b)2 + string b But I get a IndexError: list index out of range Error. I c…