“Tupel schneiden in Python” Code-Antworten

Tupel schneiden

# a[start:stop:step], default step is 1
a = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
b = a[1:3] # Note that the last index is not included
print(b)
b = a[2:] # until the end
print(b)
b = a[:3] # from beginning
print(b)
b = a[::2] # start to end with every second item
print(b)
b = a[::-1] # reverse tuple
print(b)
Tough Tarsier

Tupel schneiden in Python

# Slicing of a Tuple
 
# Slicing of a Tuple
# with Numbers
Tuple1 = tuple('Softhunt')
 
# Removing First element
print("Removal of First Element: ")
print(Tuple1[1:])
 
# Reversing the Tuple
print("\nTuple after sequence of Element is reversed: ")
print(Tuple1[::-1])
 
# Printing elements of a Range
print("\nPrinting elements between Range 4-9: ")
print(Tuple1[4:9])
Outrageous Ostrich

Ähnliche Antworten wie “Tupel schneiden in Python”

Fragen ähnlich wie “Tupel schneiden in Python”

Weitere verwandte Antworten zu “Tupel schneiden in Python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen