Yes, you can add a counter variable to the while loop and use it to limit the number of attempts. Here's an example: user_input = attempts = 0while not user_input and attempts < 3: attempts += 1 user_input = input(Enter your input: )if user_input: print(User input received:, user_input)else: print(No input received after 3 attempts.)