reverse

Why can't I use .reverse on a specific range in a list python?

Why can't I use .reverse on a specific range in a list python? Question: I am writing a simple script, where I have a list of character and I want to loop over this list and reverse the ordered of 3 elements at a time. Ex. List: a,b,c,d,e,f ; Reversed list: c,b,a,f,e,d. I tried to …

Total answers: 2

How to reverse the order of a specific column in python

How to reverse the order of a specific column in python Question: I have extracted some data online and I would like to reverse the first column order. Here is my code: import requests from bs4 import BeautifulSoup import pandas as pd data = [] soup = BeautifulSoup(requests.get("https://kworb.net/spotify/country/us_weekly.html").content, ‘html.parser’) for e in soup.select(‘#spotifyweekly tr:has(td)’): data.append({ …

Total answers: 1

Slicing str into specifing chunks reversing said chunks and adding them up back together

Slicing str into specifing chunks reversing said chunks and adding them up back together Question: I’m currently working on a challange where I need to divide strings by specifing number into chunks reverse them and than glue those reversed chunnks back together. I came up with way to execute this, however I could’t come up …

Total answers: 2

What's wrong with my code?Valid Palindrome 2- Leetcode 680

What's wrong with my code?Valid Palindrome 2- Leetcode 680 Question: Given a string s, return true if the s can be palindrome after deleting at most one character from it. Example 1: Input: s = "aba" Output: true Example 2: Input: s = "abca" Output: true Explanation: You could delete the character ‘c’. Example 3: …

Total answers: 2

reversing a sentence in python

reversing a sentence in python Question: Need to use a for loop to reverse a sentence, we are also creating a function, here is what I have, it wont print, I feel like it should work but it wont, hoping it is a minor typo. # reverse def reverse(text): rev = "" for i in …

Total answers: 3

The function is not returning an output under the if-else condition

The function is not returning an output under the if-else condition Question: After applying the queries on the given array the function is not returning the resulting array(res). ”’ Reversing the Array according to the queries. Each pair of values in queries are the starting and ending indices of the given Array(Arr). ”’ Arr = …

Total answers: 1

Print a string which has the reverse order

Print a string which has the reverse order Question: Assignment: Print a string which has the reverse order ‘Python love We. Science Data love We’ I tried this: strg = We love Data Science. We love Python words = strg.split(" ") words.reverse() new_strg = " ".join(words) print(new_strg) >>> Python love We Science. Data love We …

Total answers: 3