From 0891756a5f92da9262e51e3e33bacf3cdfd012b8 Mon Sep 17 00:00:00 2001 From: Revati Natu Date: Fri, 20 Mar 2026 00:21:12 +0530 Subject: [PATCH] fix: correct index() examples and section order in Day 4 --- 04_Day_Strings/04_strings.md | 37 ++++++++++++++++++------------------ 04_Day_Strings/day_4.py | 4 ++-- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/04_Day_Strings/04_strings.md b/04_Day_Strings/04_strings.md index 9d09d2cfe..a86297e5a 100644 --- a/04_Day_Strings/04_strings.md +++ b/04_Day_Strings/04_strings.md @@ -21,8 +21,8 @@ - [Day 4](#day-4) - [Strings](#strings) - [Creating a String](#creating-a-string) - - [String Concatenation](#string-concatenation) - [Escape Sequences in Strings](#escape-sequences-in-strings) + - [String Concatenation](#string-concatenation) - [String formatting](#string-formatting) - [Old Style String Formatting (% Operator)](#old-style-string-formatting--operator) - [New Style String Formatting (str.format)](#new-style-string-formatting-strformat) @@ -70,23 +70,6 @@ That is why I created 30 days of python.""" print(multiline_string) ``` -### String Concatenation - -We can connect strings together. Merging or connecting strings is called concatenation. See the example below: - -```py -first_name = 'Asabeneh' -last_name = 'Yetayeh' -space = ' ' -full_name = first_name + space + last_name -print(full_name) # Asabeneh Yetayeh -# Checking the length of a string using len() built-in function -print(len(first_name)) # 8 -print(len(last_name)) # 7 -print(len(first_name) > len(last_name)) # True -print(len(full_name)) # 16 -``` - ### Escape Sequences in Strings In Python and other programming languages \ followed by a character is an escape sequence. Let us see the most common escape characters: @@ -121,6 +104,24 @@ This is a backslash symbol (\) In every programming language it starts with "Hello, World!" ``` + +### String Concatenation + +We can connect strings together. Merging or connecting strings is called concatenation. See the example below: + +```py +first_name = 'Asabeneh' +last_name = 'Yetayeh' +space = ' ' +full_name = first_name + space + last_name +print(full_name) # Asabeneh Yetayeh +# Checking the length of a string using len() built-in function +print(len(first_name)) # 8 +print(len(last_name)) # 7 +print(len(first_name) > len(last_name)) # True +print(len(full_name)) # 16 +``` + ### String formatting #### Old Style String Formatting (% Operator) diff --git a/04_Day_Strings/day_4.py b/04_Day_Strings/day_4.py index 54e59464b..00c6bff7c 100644 --- a/04_Day_Strings/day_4.py +++ b/04_Day_Strings/day_4.py @@ -135,8 +135,8 @@ # index(): Returns the index of substring challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 +print(challenge.index('y')) # 5 +print(challenge.index('th')) # 0 # isalnum(): Checks alphanumeric character