Write a Python program to find the first repeated word in a given string
- برمجة
- برمجة بايثون
- 2021-04-15
- salsabeelalhams99111801528
الأجوبة
def first_repeated_word(str1):
temp = set()
for word in str1.split():
if word in temp:
return word;
else:
temp.add(word)
return 'None'
print(first_repeated_word("ab ca bc ab"))
print(first_repeated_word("ab ca bc ab ca ab bc"))
print(first_repeated_word("ab ca bc ca ab bc"))
print(first_repeated_word("ab ca bc"))
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال