FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Update 42_forty_two.py by LegendJurai · Pull Request #116 · codedex-io/python-101 · GitHub

Update 42_forty_two.py - #116

Open
LegendJurai wants to merge 1 commit into
codedex-io:mainfrom
LegendJurai:patch-5
Open

Update 42_forty_two.py#116
LegendJurai wants to merge 1 commit into
codedex-io:mainfrom
LegendJurai:patch-5

Conversation

Copy link
Copy Markdown

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'.

Copy link
Copy Markdown

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!")

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL