Sentence Flipper – Python Source Code

  • Code
  • Code With GUI
Python
print ("**Sentence Flipper**")

# Taking Input From User
user_sentence = input ("Enter Your Sentence")

# Flip The Sentence
flipped_Sentence = user_sentence[::-1]

# Print Flipping Sentence
print (flipped_Sentence)

# Word And Character Counter - By Codotix
Python
# Import Tkinter module
import tkinter as tk

#  # Creating a function to flip the sentence
def flipping_sentence():
    user_input = user_sentence.get("1.0", tk.END).rstrip()
    flipping_sentence = user_input[::-1]
    user_sentence.delete("1.0", tk.END)
    user_sentence.insert("1.0", flipping_sentence)


# Create the main Tkinter window
root = tk.Tk()
root.title("Sentence Flipper")

# Text input area
user_sentence = tk.Text(root, font=16)
user_sentence.pack(fill=tk.BOTH, expand=True)

# Button to flip the sentence
flip_button = tk.Button(root, text="Flip", font=16, command=flipping_sentence)
flip_button.pack()


# Start the main event loop
root.mainloop()


# Sentence Flipper(GUI) - By Codotix

Leave a Comment

Your email address will not be published. Required fields are marked *