Linked Questions

Score of 4708
38 answers
3271048 views

How does Python's slice notation work? That is: when I write code like a[x:y:z], a[:], a[::2] etc., how can I understand which elements end up in the slice? See Why are slice and range upper-bound ...
Score of 544
2 answers
925374 views

I have the following string: "aaaabbbb" How can I get the last four characters and store them in a string using Python?
Score of 36
8 answers
155399 views

I have a file path as a string and trying to remove the last '/' from the end. my_file_path = '/home/ro/A_Python_Scripts/flask-auto/myDirectory/scarlett Johanson/1448543562.17.jpg/' I've been trying ...
user avatar
Score of 28
3 answers
96724 views

Possible Duplicate: Is there a way to substring a string in Python? I have a string in the form 'AAAH8192375948'. How do I keep the first 5 characters of this string, and strip all the rest? Is it ...
Score of 10
1 answer
86689 views

How can I get the last character of this string? seed_name = "Cocoa"
Score of -1
2 answers
76477 views

def PrintThree(s): x = len(s) return s[0:3] + x[3:] I am pretty stuck right now on how to print only certain parts of a string. I am trying to make a code where python will print 3 ...
Score of 4
1 answer
5254 views

I have a list of strings in the format: 'foo7bar'. How is it possible in Python to remove the 7 along with any characters that follow? This is similar to this question, but I need the answer for ...
Score of 1
5 answers
4147 views

I am trying to answer a question for a homework assignment. I have to split an input of numbers into a phone number. The input is 8005551212 and the output needs to look like 800-555-1212. My question ...
Score of 2
2 answers
1400 views

I am trying to find a substring within a larger string in python. I am trying to find the text present after the string "Requests per second:" is found. It seems my knowledge of python strings and ...
Score of 1
1 answer
2829 views

I want to display an input() string and want to display it so it prints all the letters of the string except the first letter. string1 = input("enter first string") string2 = input("enter second ...
Score of -6
1 answer
1529 views

In Python: How do I write a function that would remove "x" number of characters from the beginning of a string? For instance if my string was "gorilla" and I want to be able remove two letters it ...
Score of -2
1 answer
1314 views

I need to extract the last two characters of a phrase, but I don't know how as there isn't a minus 0.
Score of 1
2 answers
882 views

get_list_of_countries_whose_nth_letter_is(3, “m”) would return a list of every country whose THIRD letter (i.e. index 2) is the letter m: ['Armenia', 'Cambodia', 'Cameroon', 'Comoros', 'Dominica', '...
Score of -2
3 answers
1265 views

I'm new to Python and to Regex. Here is my current problem, for which I have not managed to find any straight answer online. I have a string of 5 or more characters, for which I need to search for all ...
Score of -2
1 answer
161 views

Let's say I have an input: SA3213023215 I want to move the SA to the very end of the input. How can I do this?

15 30 50 per page
1
2 3 4 5