Yahoo Poland Wyszukiwanie w Internecie

Search results

  1. def reverse(text): # Container for reversed string txet="" # store the length of the string to be reversed # account for indexes starting at 0 length = len(text)-1 # loop through the string in reverse and append each character # deprecate the length index while length>=0: txet += "%s"%text[length] length-=1 return txet

  2. 4 sty 2023 · def reverse(text): chars= [] l = len(text) last = l-1 for i in range (l): chars.append(text[last]) last-=1 result= "" for c in chars: result += c return result print reverse('hola') Share Improve this answer

  3. 21 sie 2024 · To reverse the order of elements in lists, strings, or other iterable data structures, you can use slicing or the reversed() function. Example using slicing: my_list = [1, 2, 3, 4, 5]

  4. 28 lut 2024 · By combining the range() function with the length of the sequence, one can iterate over the indices of the list in reverse order. This allows direct access to the elements based on their index. Here’s an example: seq = [1, 2, 3, 4] for index in range(len(seq) - 1, -1, -1): print(seq[index]) Output: 4. 3.

  5. 9 kwi 2024 · Convert the enumerate object to a list and reverse the list. Use a for loop to iterate over the string in reverse order.

  6. Another way to create a reverse loop in Python is to use the built-in range() function with a negative step value. For example range(5, 0, -1) will return a list of numbers from 5 to 1 in reverse order.

  7. 7 wrz 2022 · Learn how to reverse a range in Python using the range(), reversed(), and sorted() functions.

  1. Ludzie szukają również