def letter_check(s):
first_letter= s[0] #stores the first character of the string in a variable
for i in range (0,len(s)):
if(s[i]==" "): #locates the space in the string
space_id=i
if(s[0]==s[space_id+1]): #compares the first letter with the letter after space
return[True]
else:
return[False]
下面的代码首先将字符串的第一个字符存储在变量中,然后定位字符串中的第一个空格,然后比较第一个字符和空格后的第一个字符并相应地返回。在
上面的函数应该能做到这一点。在
相关问题 更多 >
编程相关推荐