How to get the half of any string in Python?

Q. Given a string of even length, return the first half. So the string “woohoo” yields “woo”?

string_name = string_name[: (length_of_string) // 2]
change length of string for even and odd.

s = "woohoo"
n = len(s)//2
str1 = s[:n] # 1st half of s
str2 = s[n:] # 2nd half of s
print(str1)
print(str2)