Quick actions

cmd+k|ctrl+k

Navigation

Languages

String indexes

Snippet info

Language

Python

Visibility

public

Author

andromachi.vasileiou

Created

2026-01-15T10:40:49.554232Z

Updated

2026-01-15T13:39:05.143158Z

#String indexes _it shows how the info is stored in the computer
selfish = "me me me"
         # 01234567
print(selfish[1:5])
print(selfish) #prints from 0-7

#[start] the first item in [] is called the start. It says "where do you want me to look?"
#[start:stop] "Where do you want me to stop?". It stops before the number you put
print(selfish[0:8])

#[start:stop:stepover] ποσα προσπερναει

print(selfish[0:8:2])

print(selfish[1:]) #ends at default

print(selfish[:5]) #starts at default

print(selfish[::1])

print(selfish[-1]) #starts at the end of the string

print(selfish[::-1]) #the reverse of the string

#immutability ->strings in python cannot be changed

selfish = 100
print(selfish)

#you can rewrite the word but not the numbers in which the word is assigned

selfish[0] = "8"
print(selfish)
INFO