Guessing of a number using While loop

Time Complexity: The time complexity of this code is O(n) as the number of iterations of the loop is not fixed and depends on the number of guesses taken by the user to get the right answer. Space Complexity: The space complexity of this code is O(1) as all the variables used in this code are of the same size and no extra space is required to store the values.