Bug: The code examples on the main page don't match their source code

Open Beginner friendly
#3,137 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
documentation

Research direction

Start with apps/codesamples/factories.py and compare its examples with the rendered code on https://www.python.org, as described in the reproduction steps. Trace the source-to-website output and verify that the main-page examples match the source code, including links, formatting, prompts, and output.

Written by the indexing model from the issue text.

Description

bug
Describe the bug

Here's a diff between what the html should look like according to the source code and the website

diff --git a/source.md b/website.md
index fb765d0..6a4ea3c 100644
--- a/source.md
+++ b/website.md
@@ -2,8 +2,8 @@
 <p>Experienced programmers in any other language can pick up Python very
 quickly, and beginners find the clean syntax and indentation structure
 easy to learn.
-<a href="https://docs.python.org/3/tutorial/">Whet your appetite</a>
-with our Python overview.</p>
+<a href="//docs.python.org/3/tutorial/">Whet your appetite</a>
+with our Python&nbsp;3 overview.</p>
 
 ```python
 # Simple output (with Unicode)
@@ -23,9 +23,7 @@ Hi, Python.
 straightforward: the operators <code>+</code>, <code>-</code>,
 <code>*</code> and <code>/</code> work as expected; parentheses
 <code>()</code> can be used for grouping.
-<a href="https://docs.python.org/3/tutorial/introduction.html
-#using-python-as-a-calculator">More about simple math functions</a>.
-</p>
+<a href="http://docs.python.org/3/tutorial/introduction.html#using-python-as-a-calculator">More about simple math functions in Python&nbsp;3</a>.</p>
 
 ```python
 # Simple arithmetic
@@ -43,11 +41,10 @@ straightforward: the operators <code>+</code>, <code>-</code>,
 <p>Lists (known as arrays in other languages) are one of the
 compound data types that Python understands. Lists can be indexed,
 sliced and manipulated with other built-in functions.
-<a href="https://docs.python.org/3/tutorial/introduction.html
-#lists">More about lists</a></p>
+<a href="//docs.python.org/3/tutorial/introduction.html#lists">More about lists in Python&nbsp;3</a></p>
 
 ```python
-# List comprehensions
+# Python 3: List comprehensions
 >>> fruits = ['Banana', 'Apple', 'Lime']
 >>> loud_fruits = [fruit.upper() for fruit in fruits]
 >>> print(loud_fruits)
@@ -63,16 +60,16 @@ sliced and manipulated with other built-in functions.
 languages speak &mdash; <code>if</code>, <code>for</code>,
 <code>while</code> and <code>range</code> &mdash; with some of
 its own twists, of course.
-<a href="https://docs.python.org/3/tutorial/controlflow.html">
-More control flow tools</a></p>
+<a href="//docs.python.org/3/tutorial/controlflow.html">
+More control flow tools in Python&nbsp;3</a></p>
 
 ```python
 # For loop on a list
 >>> numbers = [2, 4, 6, 8]
 >>> product = 1
 >>> for number in numbers:
-...     product = product * number
-...
+...    product = product * number
+... 
 >>> print('The product is:', product)
 The product is: 384
 ```
@@ -81,18 +78,16 @@ The product is: 384
 <p>The core of extensible programming is defining functions.
 Python allows mandatory and optional arguments, keyword arguments,
 and even arbitrary argument lists.
-<a href="https://docs.python.org/3/tutorial/controlflow.html
-#defining-functions">More about defining functions</a></p>
+<a href="//docs.python.org/3/tutorial/controlflow.html#defining-functions">More about defining functions in Python&nbsp;3</a></p>
 
 ```python
-# Write Fibonacci series up to n
+# Python 3: Fibonacci series up to n
 >>> def fib(n):
-...     a, b = 0, 1
-...     while a < n:
-...         print(a, end=' ')
-...         a, b = b, a+b
-...     print()
-...
+>>>     a, b = 0, 1
+>>>     while a < n:
+>>>         print(a, end=' ')
+>>>         a, b = b, a+b
+>>>     print()
 >>> fib(1000)
-0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610
+0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
To Reproduce
  1. Go to https://www.python.org
  2. Compare with https://github.com/python/pythondotorg/blob/main/apps/codesamples/factories.py
Expected behavior

I would expect the website to match the source code.

URL to the issue

No response

Screenshots

Browsers

Safari

Operating System

macOS

Browser Version

18.6

Relevant log output

Additional context

No response

Dominant language
Python
Stars
1.7k
Forks
700
Avg merge
1d 23h
Merged PRs (30d)
14

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python/pythondotorg

All issues in python/pythondotorg

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.