# Initialize the smallest_input with a large value smallest_input = float('inf') # Use a while loop to get user input until 0 is entered while True: user_input = float(input("Enter a value (enter 0 to finish): ")) # Check if the user wants to finish if user_input == 0: break # Compare with the current smallest_input if user_input < smallest_input: smallest_input = user_input # Display the result print("The smallest input is:", smallest_input)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter