Linked Questions

Score of 122
10 answers
237961 views

I'm sure this is covered in plenty of places, but I don't know the exact name of the action I'm trying to do so I can't really look it up. I've been reading an official Python book for 30 minutes ...
Score of 72
2 answers
77468 views

I have two scenarios where I need to pad a string with whitespaces up to a certain length, in both the left and right directions (in separate cases). For instance, I have the string: TEST but I need ...
Score of 2
1 answer
7180 views

Is it possible to print multiple strings on one line in such a way that the final string will always be x amount of space from the left? For example, is there anyway to print a result similar to this, ...
Score of -1
1 answer
1242 views

I want to produce a similar shape to the above using a nested loop. Can anyone here help me with that? print(' #') print(' ###') print(' ####') print(' #####') print(' #######'...
Score of 1
1 answer
1862 views

Sorry if this question has been asked before, (Yes, I've checked) but I am writing a program for Python 3.6 and having difficulty trying to align the output of columns like so: 0, 0, 0, // - ...
Score of -3
5 answers
283 views

I want to padding spaces of each input item if it is less than 5 characters, Then padding each to 5 characters long. How to do it with Python input = [477 , 4770, 47711] output = ["477 ", "4770 "...
Score of 0
3 answers
195 views

I am trying to have a user input a word and a certain number of spaces before it: e.g. if the user wants 10 spaces before a word it will print: ..........foo But without the .'s (That's just to make ...
Score of -3
2 answers
270 views

Is there a custom way of padding lines of text in python, I am using the escape characters "\t", but I wonder if there is an alternative. for example print('My Name is:') print('Rambo') print('Mambo')...
Score of 0
1 answer
210 views

I have a text file called animal.txt. 1.1 Animal Name : Dog Animal Type : Mammal Fur : Yes Scale : No 1.2 Animal Name : Snake Animal Type : Reptile Fur ...
Score of 0
1 answer
98 views

I am writing a file which gets information about stock items from a csv, the issue is that most of the stock item IDs are 4 digits long, but some of them are 2 or 3 digits, and the remaining digits ...
user avatar
Score of 0
3 answers
111 views

I have two arrays with words. One is the words before processing, the second is after. before = ['screen', 'properly', 'salients', 'spoiled', 'respond'] after = ['screens', 'properly', 'salient', '...
Score of 0
1 answer
86 views

I have written below code to display a leading zero when the string representation of date has less than two digits? '{}-{}-{:02d}'.format('6th', 'Jun', '1933') But it is failing with an error: ...
Score of 0
0 answers
52 views

I have a coding assignment to line up data in columns. Current code: print('i i**2 i**3 2**i',sep=' ') for i in range(1,13): print(i, i**2,i**3,2**i,sep=' ') I have written this code. Kindly ...
Score of 0
1 answer
53 views

I am trying to run a loop and I want to use print() on 1 line only but here it needs long spacing so that the letters are not overwritten from the previous print result, and for that I really need ...
Score of 201
8 answers
466073 views

I have the following code (printing the occurrence of all permutations in a string): def splitter(str): for i in range(1, len(str)): start = str[0:i] end = str[i:] yield (...

15 30 50 per page
1
2 3 4 5