Q. Write a program that inputs a word and prints "Yes it starts !!" if the given word starts with "0", "1", "2", ... , "9".

Answer :-

str = input ("Enter the word :- ")
if str[0].isdigit() :
    print ("Yes it starts !!" )
else :
    print("The string does not start with 0, 1, 2, ... , 9")

Output :-

Enter the word :- 05Path
Yes it starts !!

>>> 

Enter the word :- Path Walla
The string does not start with 0, 1, 2, ... , 9

>>> 

Enter the word :- 9Walla
Yes it starts !!

>>> 


4 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post