Slicing

text = 'HelloWorld!'
n = 5
result = text[:n]

print(result)  # Hello

Leave a Comment

Your email address will not be published. Required fields are marked *