Skip to content
Advertisement

Too Much Wait TIme

So I was trying to use a procedure(with a parameter)…I asked the user for inputs and created a validate function to check the inputs and see if they are strings…I checked it but the outputs are taking too long to output. How do I fix this?

I tried:

JavaScript
JavaScript

But it came out to be:

Enter first character(lower cases) or press Enter: 2

And from there it takes too much time to say it it must be a string…

Thank you in advance!

Advertisement

Answer

the input() function in python always take the inputs as string, if you want to get integer as input then the following functions would be used => int(input())

it is not taking too long to execute it just a logical error in your code ;)

lets say the the input is "hello" so the len("hello") is 5

now , the input goes to the validation function(your function) first it starts with infinite while loop with no terminal condition and starts to checks the condition len(LETTER) == 0 whether it is true or false but it won’t raise any exception so it won’t go to the except block where the actual terminal condition is located(break) so its keep running forever.

hope it’ll be helpful for you, thank you.

Advertisement