programming-examples/python/String/Python function to get a string made of its first three characters of a specified string.py

6 lines
163 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
def first_three(str):
return str[:3] if len(str) > 3 else str
print(first_three('ipy'))
print(first_three('python'))
print(first_three('py'))