My QA Projects

QA Projects I was involded.

View on GitHub

String Indexing and Slicing

String Indexing

Index operator

Syntax

    string[index]

s = “UC Berkeley”

Index 0 1 2 3 4 5 6 7 8 9 10 Character U C B e r k e l e y

Negative Indexes

Negative Indexes Example

s = “UC Berkeley”

Index -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 Character U C B e r k e k e y

String slicing

s = “UC Berkeley”

Index 0 1 2 3 4 5 6 7 8 9 10 Character U C B e r k e k e y

s[3:11]
#Output
Berkeley

Index operator (Slice)

string[start:stop]

Default Slice Values Examples

s[:stop]
# equivalent
s[0:stop]
s = "University of California"
print(s[0:10])
print(s[:10])
# Output
University
University

Default Slice Values

s[start:]
# equivalent
s[start:len(s)]
# stop index of the length of s
s = "University of California"
print(s[11:len(s)])
print(s[11:])
# Output
of California
of California