I've created a function who makes a loading bar in the terminal window. It looks like this:
def loadingBar(length, time):
void = '-'
fill = '#'
count = 100/length
increaseCount = 0
sleepTime = time/20
for i in range(length):
print('['+(fill*i)+(void*(length-i))+'] '+str(int(increaseCount))+'%',end='\r')
increaseCount += count
time.sleep(sleepTime)
print('['+(fill*(i+1))+(void*(length-(i+1)))+'] '+str(int(increaseCount))+'%',end='\n')
I want to customize the sleep time with the variable “sleepTime”, but I have an error who says :
AttributeError: 'float' object has no attribute 'sleep'
I don't understand because the variable “time” and the variable “sleepTime” are float!
Note : I'm not very good at English.