Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Filename: to_kebab_case.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- """
- Description:
- This script converts input text to Kebab Case, where spaces are replaced with hyphens ('-').
- The converted text is then saved to a file named "converted_kebab_case.txt" in UTF-8 encoding.
- Requirements:
- - Python 3.x
- Functions:
- - to_kebab_case(text): Converts input text to Kebab Case.
- Parameters:
- text (str): The input text to be converted.
- Returns:
- str: The text converted to Kebab Case.
- Usage:
- Run the script and provide the text you want to convert when prompted.
- The converted text will be saved to "converted_kebab_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_kebab_case.txt'.
- Converted Text:
- this-is-a-test-of-case-converting
- """
- def to_kebab_case(text):
- """
- Converts input text to Kebab Case.
- Parameters:
- text (str): The input text to be converted.
- Returns:
- str: The text converted to Kebab Case.
- """
- return '-'.join(text.lower().split())
- def main():
- """
- Main function of the script.
- Prompts the user to input text, converts it to Kebab Case,
- and saves the converted text to a file named "converted_kebab_case.txt".
- """
- input_text = input("Enter the text you want to convert to Kebab Case: ")
- kebab_case_text = to_kebab_case(input_text)
- with open("converted_kebab_case.txt", "w", encoding="utf-8") as file:
- file.write(kebab_case_text)
- print(f"\nConverted Text Has Been Saved To: 'converted_kebab_case.txt'.\n\nConverted Text:\n\t\t{kebab_case_text}")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement