Write a Python program to remove duplicate words from a given string use collections module

  • برمجة
  • برمجة بايثون

Write a Python program to remove duplicate words from a given string use collections module

الأجوبة

from collections import OrderedDict
text_str = "Python Exercises Practice Solution Exercises"
print("Original String:")
print(text_str)
print("\nAfter removing duplicate words from the said string:")
result = ' '.join(OrderedDict((w,w) for w in text_str.split()).keys())
print(result)
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...