“Umgekehrter Python” Code-Antworten

Umgekehrter Python

# for string
seq_string = 'Python'
print(list(reversed(seq_string)))

# for tuple
seq_tuple = ('P', 'y', 't', 'h', 'o', 'n')
print(list(reversed(seq_tuple)))

# for range
seq_range = range(5, 9)
print(list(reversed(seq_range)))

# for list
seq_list = [1, 2, 4, 3, 5]
print(list(reversed(seq_list)))
Bacem OBEY

umgekehrt () Python

#reversed() is used to reverse the order of elements of a str or a container
#you can't reverse a string and convert it back to a string using str()
a='redrum' ; b='ypareht deen I'
x=list(reversed(a))
y=list(reversed(b))
print(x)    #yeilds ['m','u','r','d','e','r']
print(y)    #yeilds['I',' ','n','e','e','d',' ','t','h','e','r','a','p','y']
#if we want a string version of the list, we can use the .join function
c=''.join(x) ; d=''.join(y)
print(c)    #yeilds: murder
print(d)    #yeilds: I need therapy
Purple Team

Umgekehrter Funktion Python

w=["ab","e","e3"]
res = reversed(w)
// res is array w reversed ["e3","e","ab"]
ap_Cooperative_dev

Ähnliche Antworten wie “Umgekehrter Python”

Fragen ähnlich wie “Umgekehrter Python”

Weitere verwandte Antworten zu “Umgekehrter Python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen