sen=input ("Enter a sentence: ")
index=0
for i in sen:
if i<=len(sen):
if sen[i]!=' ':
print(sen[i])
exit()
You can just iterate trought the string, check for Spaces and then take the Charakter after the space:
def main(string):
count = 0
output = []
for _ in string:
if string[count] == ' ':
output.append(string[count + 1])
count += 1
return output
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.