From 6335c97d5634f19145140f5ec19718bc81e72d0f Mon Sep 17 00:00:00 2001 From: Kagan D <226443830+kagandavran@users.noreply.github.com> Date: Sat, 16 Aug 2025 10:15:14 -0700 Subject: [PATCH 1/3] Improve bottle singular/plural handling using only class-taught concepts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added an alternative solution that handles the singular and plural spelling of “bottle” based on the number remaining. This version only uses the concepts that have been introduced in class up to this point. --- 4-loops/20_99_bottles_2.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 4-loops/20_99_bottles_2.py diff --git a/4-loops/20_99_bottles_2.py b/4-loops/20_99_bottles_2.py new file mode 100644 index 0000000..b30b92a --- /dev/null +++ b/4-loops/20_99_bottles_2.py @@ -0,0 +1,14 @@ +# 99 Bottles of Beer 🍻 +# Codédex + +for i in range(99, 0, -1): + if i > 1: + print(f'{i} bottles of beer on the wall') + print(f'{i} bottles of beer') + print(f'Take one down, pass it around') + print(f'{i-1} bottles of beer on the wall\n') + else: + print(f'{i} bottle of beer on the wall') + print(f'{i} bottle of beer') + print(f'Take one down, pass it around') + print(f'No more bottles of beer on the wall\n') From 2af5ca9ba0ec365ddfd9c7f7d4a1f8535f393d16 Mon Sep 17 00:00:00 2001 From: Kagan D <226443830+kagandavran@users.noreply.github.com> Date: Sat, 16 Aug 2025 10:19:08 -0700 Subject: [PATCH 2/3] Add alternative solution link to README table of contents Updated the README table of contents to include a hyperlink to the new bottle pluralization solution under loops path. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cb56759..126475d 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Welcome to The Legend of Python GitHub repo! We are super excited to have you. H - [`guess_number.py`](https://github.com/codedex-io/python-101/blob/main/4-loops/18_guess_number.py) - [`detention.py`](https://github.com/codedex-io/python-101/blob/main/4-loops/19_detention.py) - [`99_bottles.py`](https://github.com/codedex-io/python-101/blob/main/4-loops/20_99_bottles.py) +- [`99_bottles.py`](https://github.com/codedex-io/python-101/blob/main/4-loops/20_99_bottles_2.py) (solution 2) - [`fizz_buzz.py`](https://github.com/codedex-io/python-101/blob/main/4-loops/21_fizz_buzz.py) ## Lists From d363e6c85e84918f2cd3aa02c9abccd7ca968d64 Mon Sep 17 00:00:00 2001 From: Kagan D <226443830+kagandavran@users.noreply.github.com> Date: Sat, 16 Aug 2025 10:21:29 -0700 Subject: [PATCH 3/3] Add alternative solution link to README table of contents Updated the README table of contents to include a hyperlink to the new bottle pluralization solution. Also appended "(solution 1)" to the end of the original solution file. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 126475d..569ea2e 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Welcome to The Legend of Python GitHub repo! We are super excited to have you. H - [`enter_pin.py`](https://github.com/codedex-io/python-101/blob/main/4-loops/17_enter_pin.py) - [`guess_number.py`](https://github.com/codedex-io/python-101/blob/main/4-loops/18_guess_number.py) - [`detention.py`](https://github.com/codedex-io/python-101/blob/main/4-loops/19_detention.py) -- [`99_bottles.py`](https://github.com/codedex-io/python-101/blob/main/4-loops/20_99_bottles.py) +- [`99_bottles.py`](https://github.com/codedex-io/python-101/blob/main/4-loops/20_99_bottles.py) (solution 1) - [`99_bottles.py`](https://github.com/codedex-io/python-101/blob/main/4-loops/20_99_bottles_2.py) (solution 2) - [`fizz_buzz.py`](https://github.com/codedex-io/python-101/blob/main/4-loops/21_fizz_buzz.py)