From 79d935e42560e832f4a76e8d21d418f2a557cdb8 Mon Sep 17 00:00:00 2001 From: MahmoudHosamGaber <89939442+MahmoudHosamGaber@users.noreply.github.com> Date: Fri, 21 Jan 2022 19:17:06 +0200 Subject: [PATCH] Update StringSlicing.py --- .../StringSlicing.py | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Lesson 6 - String Manipulation/StringSlicing.py b/Lesson 6 - String Manipulation/StringSlicing.py index ab57cbd..e8ce8ff 100644 --- a/Lesson 6 - String Manipulation/StringSlicing.py +++ b/Lesson 6 - String Manipulation/StringSlicing.py @@ -1,20 +1,21 @@ word = "photosynthesis" -#otosy + print(word[2:7]) #strts from 2 and ends before 7 -#photo +# Result : otosy print(word[:5]) #ends before 5 -#photosynthesis +# Result : photo print(word[:]) #print whole string -#ptyhi +# Result : photosynthesis print(word[::3]) #print 0 and multiple of 3 afterwards -#tyhi +# Result : ptyhi print(word[3::3]) #print 3 and multiple of 3 afterwards -#photosynthesi +# Result : tyhi print(word[:-1]) #ends before -1 -#photosy +# Result : photosynthesi print(word[:-7]) #ends before -7 -#sisehtnysotohp +# Result : photosy print(word[::-1]) #print string in reverse -#sotohp -print(word[5::-1]) #print reverse till 5 \ No newline at end of file +# Result : sisehtnysotohp +print(word[5::-1]) #print reverse till 5 +# Result : sotohp