def fun_connect(s1, s2):
retrun s1[:-1]+s2[:-1]
def fun_connext(str1, str2):
"""字符串拼接"""
print(str1[:-1] + str2[:-1])
str1 = input('输入字符串1: ')
str2 = input('输入字符串2: ')
fun_connext(str1, str2)
不知道你这个问题是否已经解决, 如果还没有解决的话:有帮助的话,请点采纳该答案~
是的,我可以提供一个名为fun_connect的函数来实现这个功能。以下是Python代码:
def fun_connect(str1, str2):
"""
This function takes in two strings, remove their last character and concatenate them together.
"""
if len(str1) > 0 and len(str2) > 0:
return str1[:-1] + str2[:-1]
else:
return "Invalid input!"
使用方法:
str1 = "Hello"
str2 = "World"
result = fun_connect(str1, str2)
print(result) # "HellWorl"