Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Filename: to_uppercase.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- """
- Description:
- This script converts input text to Uppercase format, where all letters are in uppercase.
- The converted text is then saved to a file named "converted_uppercase.txt" in UTF-8 encoding.
- Requirements:
- - Python 3.x
- Functions:
- - to_uppercase(text): Converts input text to Uppercase format.
- Parameters:
- text (str): The input text to be converted.
- Returns:
- str: The text converted to Uppercase format.
- Usage:
- Run the script and provide the text you want to convert when prompted.
- The converted text will be saved to "converted_uppercase.txt" in the same directory as the script.
- Example Output:
- Input Text: "This is a Test of Case Converting"
- Converted Text Has Been Saved To: 'converted_uppercase.txt'.
- Converted Text:
- THIS IS A TEST OF CASE CONVERTING
- """
- def to_uppercase(text):
- """
- Convert a given string to Uppercase format.
- Parameters:
- text (str): The input string.
- Returns:
- str: The Uppercase converted string.
- """
- return text.upper()
- def main():
- """
- Main function to prompt user input and convert the text to Uppercase.
- The converted text is saved to a file.
- """
- input_text = input("Enter the text you want to convert to Uppercase: ")
- uppercase_text = to_uppercase(input_text)
- with open("converted_uppercase.txt", "w", encoding="utf-8") as file:
- file.write(uppercase_text)
- print("\nConverted Text Has Been Saved To: 'converted_uppercase.txt'.\n")
- print("Converted Text:\n")
- print(f"\t\t{uppercase_text}")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement