Skip to content

Conversation

@LegendJurai
Copy link

Actually, the '.search' command doesn't work (in my code editor). And in the instructions there was an external link which also says it should be '.summary'.

Actually, the '.search' command doesn't work (in my code editor). And in the instructions there was an external link which also says it should be '.summary'.
@asimhusain-ai
Copy link

import wikipedia

wikipedia.set_lang("en")
topic = input("Enter a topic: ").strip()

try:
print("\nSummary:\n", wikipedia.summary(topic, sentences=3))
print("\nRelated articles:", ", ".join(wikipedia.search(topic)[:5]))
except wikipedia.exceptions.DisambiguationError as e:
print("Multiple options:", ", ".join(e.options[:5]))
except wikipedia.exceptions.PageError:
print("Page not found!")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants