DAY 5 of PYTHON top 100 questions : from Basic to Advanced !!

Hello, I'm Priya Chakraborty, a dedicated B.Tech student in Electrical Engineering at Siliguri Institute Of Technology. I'm an enthusiastic learner, constantly seeking to expand my skill set and knowledge base. With a solid foundation in programming languages such as C, R, Python, and MySQL, I'm poised to tackle complex technical challenges.
But my passions extend beyond the realm of engineering. I'm also an aspiring content writer, driven by a curiosity to communicate ideas, both technical and non-technical, in a way that captivates and educates.
My journey is defined by a relentless pursuit of self-improvement, coupled with strong communication skills. I believe in the power of continuous learning and the importance of sharing knowledge.
Write a Python program to reverse a given string:-
str=input("Enter the string : ")
print('THE REVERSE OF THE STRING IS :- ',str[::-1])
Output :
Enter the string : PRIYA
THE REVERSE OF THE STRING IS :- AYIRP
This is a Python code that takes a string as input from the user, then prints the reverse of the string using slicing. Here's how the code works:
The input() function is used to take input from the user. Whatever the user types in are stored in the variable 'str'.
The slicing notation [::-1] is used to reverse the string. The notation means "Start at the end of the string and keep going back until the beginning, with a step of -1". This results in the string being reversed.
The reversed string is then printed using the print() function.
If you are a beginner and want to know more about Python programming, you can read my Basics of Python blogs (From part 1 to part 15).
HAPPY LEARNING !!!




