PROBLEM 41 : First & Last
A program to find whether the first digit of the input and the last digit of the input are same or not.
Author - Ajay Zad
date - 07/03/2022
num = int(input("Enter the number :"))
#Converting from int data type to string data type
string = str(num)
#Finding the length of the string
length = len(string)
#Comparing for equality
if string[0] == string[length-1]:
print("Both the digits are same")
else:
print("Both the digits are not same")
Input :
Enter the number : 10011
Output :
Both the digits are same
Input :
Enter the number : 10022
Output:
Both the digits are not same
No comments:
Post a Comment