Computer Science, asked by manerohit9529, 7 months ago

write a program to calculate weight of string for example input abc output 6 second example input //program to input string and check given string is palindrome or not. if palindrome print 1 else print -1
//nitin nitin latur rutal 72​

Answers

Answered by amogh7353
0

Answer:

Where is this question please send

Answered by satyam21461
0

s = input("Enter a string: ")

if s[0:] == s[::-1]:

 print("The string is a palindrome.")

else:

 print("The string isn't a palindrome.")

The above program can be done using string slicing.

String slicing is the act of extracting a substring from a given string. In order to do so, one must understand how to declare each character's index values.

Positive indexing starts traversing through the string forwards and starts with the index value 0.

Negative indexing starts traversing through the string backwards and starts with the index value -1.

When you give a negative number as the step value, the string is read in its reverse order.

Similar questions