Im trying to iterate through a string and return the string length that has been declared in the function.
It will receive two parameters, x and chars. The function will return a string that is comprised of the values in chars from index 0 up to the index x-1.
The return I want to receive is
print rangeLoopStringParam1("bobsyouruncle", 5)
# -> "bobsy"
print rangeLoopStringParam1("supercalifragilisticexpialidoshus", 8)
# -> "supercal"
This is the code I have so far but I feel like Im not getting very far. Can anyone guide me through this problem?
def rangeLoopStringParam1(chars, x):
for i in range(0, x, len(chars)):
chars += chars
return chars