Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update StringSlicing.py #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions Lesson 6 - String Manipulation/StringSlicing.py
Original file line number Diff line number Diff line change
@@ -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
# Result : sisehtnysotohp
print(word[5::-1]) #print reverse till 5
# Result : sotohp