Python truncate a long string?

How does one truncate a string to 75 characters in Python? This is how it is done in JavaScript: var data="saddddd...

Python - write() versus writelines() and concatenated strings?

So I'm learning Python. I am going through the lessons and ran into a problem where I had to condense a great many t...

Python - write() versus writelines() and concatenated strings?

So I'm learning Python. I am going through the lessons and ran into a problem where I had to condense a great many t...

Least square fit a 2D line?

I realize I could use numpy to find the line like so: import numpy as np import matplotlib.pyplot as plt a = np.arr...

Counting the number of True Booleans in a Python List?

I have a list of Booleans: [True, True, False, False, False, True] and I am looking for a way to count the number...

python NameError: global name '__file__' is not defined?

When I run this code in python 2.7, I get this error: Traceback (most recent call last): File "C:\Python26\Lib\site...

How to delete all instances of a character in a string in python??

How do I delete all the instances of a character in this string? Here is my code: def findreplace(char, string): ...

Dashed lines from points to axes in matplotlib?

I have a set of points which I am plotting like this: import matplotlib.pyplot as plt` x = [1,2,3,4,5,6] y = [1,4,...

Coloring only the inside of a shape?

Lets say that you are given this image and are given the instruction to programmatically color only the inside of...

5x5 Sliding Puzzle Fast & Low-Move Solution?

I am trying to find a way to programmatically solve a 24-piece sliding puzzle in a reasonable amount of time and mov...

How can I generate a list of consecutive numbers??

Say if you had a number input 8 in python and you wanted to generate a list of consecutive numbers up to 8 like [0,...

Plt.Scatter: How to add title and xlabel and ylabel?

Is there a way to add title (and xlabel and ylabel) to plt.scatter(x,y,...) or plt.plot(x,y,...) directly without wr...

How to extract account number in cheque/check images?

I am working on a task to extract the account number from cheque images. My current approach can be divided into 2 s...

How can I draw transparent lines where the color becomes stronger when they overlap??

When you draw a bunch of transparent lines in matplotlib like this, you get a nice effect; when they overlap they ar...