Write a python function to get a string made of its first three characters of a specified string. If the length of the string is less than 3, then return the original string.
Sample function and result:
first_three('ipy') ->ipy
first_three('python') ->pyt
Answers
Answered by
4
Answer:
def get_three_character(word):
if len(word)<=3:
return word
else:
return word[0:3]
print("Enter string")
inputstring=input()
output=get_three_character(inputstring)
print("returned string: "+output)
Explanation:
Similar questions