Advertisement
Python253

to_lowercase

May 23rd, 2024
663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.68 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # Filename: to_lowercase.py
  4. # Version: 1.0.0
  5. # Author: Jeoi Reqi
  6.  
  7. """
  8. Description:
  9.    This script converts input text to Lowercase format.
  10.  
  11. Requirements:
  12.    - Python 3.x
  13.  
  14. Functions:
  15.    - to_lowercase(text): Converts input text to Lowercase format.
  16.        Parameters:
  17.            text (str): The input text to be converted.
  18.        Returns:
  19.            str: The text converted to Lowercase format.
  20.  
  21. Usage:
  22.    Run the script and provide the text you want to convert when prompted.
  23.    The converted text will be saved to "converted_lowercase.txt" in the same directory as the script.
  24.  
  25. Example Output:
  26.    Input Text: "This is a Test of Case Converting"
  27.    
  28.    Converted Text Has Been Saved To: 'converted_lowercase.txt'.
  29.    
  30.    Converted Text:
  31.            this is a test of case converting
  32. """
  33.  
  34. def to_lowercase(text):
  35.     """
  36.    Convert a given string to Lowercase format.
  37.    
  38.    Parameters:
  39.        text (str): The input string.
  40.        
  41.    Returns:
  42.        str: The Lowercase converted string.
  43.    """
  44.     return text.lower()
  45.  
  46. def main():
  47.     """
  48.    Main function to prompt user input and convert the text to Lowercase.
  49.    The converted text is saved to a file.
  50.    """
  51.     input_text = input("Enter the text you want to convert to Lowercase: ")
  52.     lowercase_text = to_lowercase(input_text)
  53.    
  54.     with open("converted_lowercase.txt", "w", encoding="utf-8") as file:
  55.         file.write(lowercase_text)
  56.    
  57.     print("\nConverted Text Has Been Saved To: 'converted_lowercase.txt'.\n")
  58.     print("Converted Text:\n")
  59.     print(f"\t\t{lowercase_text}")
  60.  
  61. if __name__ == "__main__":
  62.     main()
  63.  
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement