mirror of
				https://github.com/Garmelon/PFERD.git
				synced 2025-10-31 04:42:42 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			26 lines
		
	
	
		
			616 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			616 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from typing import Optional
 | |
| 
 | |
| 
 | |
| def prompt_yes_no(query: str, default: Optional[bool]) -> bool:
 | |
|     """
 | |
|     Asks the user a yes/no question and returns their choice.
 | |
|     """
 | |
| 
 | |
|     if default is True:
 | |
|         query += " [Y/n] "
 | |
|     elif default is False:
 | |
|         query += " [y/N] "
 | |
|     else:
 | |
|         query += " [y/n] "
 | |
| 
 | |
|     while True:
 | |
|         response = input(query).strip().lower()
 | |
|         if response == "y":
 | |
|             return True
 | |
|         elif response == "n":
 | |
|             return False
 | |
|         elif response == "" and default is not None:
 | |
|             return default
 | |
| 
 | |
|         print("Please answer with 'y' or 'n'.")
 | 
