I have to define my own floating-point version of range() here. It works the same as built-in range() function but can accept float values.start, stop, and step are integer or float numbers and step is a non-zero value and it also can be negative.
I have tried looking for answers on stackoverflow but all of them only work for positive step. I keep getting stuck on a test where it tests the value (0,0.25,-1) I'm a hundred percent sure there is a quicker and faster to implement this because my program takes a long time to test all the values. can someone help me create a function to do this and I Can't user imported tools.
def float(start,stop,step):
x = start
my_list = []
if start < stop:
while x<stop:
my_list.append(x)
if x < 0:
x-=step
elif x > 0:
x+=step
else:
x+=step
return my_list
if start > stop:
while x<=start and x>stop:
my_list.append(x)
if x < 0:
x=step
elif x > 0:
x+=step
else:
x+=step
return my_list