Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Filename: to_pascal_case.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- """
- Description:
- This script converts input text to Pascal Case, where each word starts with an uppercase letter and there are no spaces between words.
- The converted text is then saved to a file named "converted_pascal_case.txt" in UTF-8 encoding.
- Requirements:
- - Python 3.x
- Functions:
- - to_pascal_case(text): Converts input text to Pascal Case.
- Parameters:
- text (str): The input text to be converted.
- Returns:
- str: The text converted to Pascal Case.
- Usage:
- Run the script and provide the text you want to convert when prompted.
- The converted text will be saved to "converted_pascal_case.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_pascal_case.txt'.
- Converted Text:
- ThisIsATestOfCaseConverting
- """
- def to_pascal_case(text):
- """
- Converts input text to Pascal Case.
- Parameters:
- text (str): The input text to be converted.
- Returns:
- str: The text converted to Pascal Case.
- """
- words = text.split()
- pascal_case_words = [word.capitalize() for word in words]
- return ''.join(pascal_case_words)
- def main():
- """
- Main function of the script.
- Prompts the user to input text, converts it to Pascal Case,
- and saves the converted text to a file named "converted_pascal_case.txt".
- """
- input_text = input("Enter the text you want to convert to Pascal Case: ")
- pascal_case_text = to_pascal_case(input_text)
- with open("converted_pascal_case.txt", "w", encoding="utf-8") as file:
- file.write(pascal_case_text)
- print(f"\nConverted Text Has Been Saved To: 'converted_pascal_case.txt'.\n\nConverted Text:\n\t\t{pascal_case_text}")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement