printing

typeerror print_slow() takes 1 positional argument but 2 were given

typeerror print_slow() takes 1 positional argument but 2 were given Question: so im fiddling around in pytbon cuz im bored and i realise i try to slow print a input i have earlier in the code i bave defined slow print ive imported every thing i need but when i run it it saw its …

Total answers: 2

Python comprehension with multiple prints

Python comprehension with multiple prints Question: I want to put this for loop into a comprehension. Is this even possible? for i in range(1, 11): result = len({tuple(walk) for (walk, distance) in dic[i] if distance == 0}) print(f’There are {result} different unique walks with length {i}’) I tried stuff like print({tuple(walk) for i in range(1, …

Total answers: 2

Print every two pairs in a new line from array of elements in Python

Print every two pairs in a new line from array of elements in Python Question: How can I print from an array of elements in Python every second pair of elements one below another, without commas and brackets? My array looks like this: m=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] …

Total answers: 4

python password generator loop problem print error

python password generator loop problem print error Question: I trying to make a password generator using python. Currently, I just want the program to print random characters from the ascii table. I will later introduce numbers and symbols. I used a for loop to print random character from a range that the user inputs. It …

Total answers: 4

Python printing tabular data

Python printing tabular data Question: Hell All, I have been trying to print tabular data from two dimensional list numerical are right aligned, strings are left aligned and width of a column is dynamically decided based on max string length in each column Example-A: table = [[‘Name’, ‘Marks’, ‘Division’, ‘ID’], [‘Raj’, 7, ‘A’, 21], [‘Shivam’, …

Total answers: 2

printing output values together with some multiplication parameter

printing output values together with some multiplication parameter Question: I tried write a code that the given numbers multiply by ten for each input, and then sum all of those values. If their summation is bigger than 100 it will stop. Furthermore I want to print the output as "Program ends because 10*3+10*1+10*8 = 120, …

Total answers: 2

Printing out function containing print and return

Printing out function containing print and return Question: I recently came across a weird problem. I assumed that the two code snippets below should have the same output, yet they do not. Can someone explain? def my_function(): myvar = "a" print("2", myvar) return myvar print("1") print(my_function()) #will output: #1 #2 a #a print("1", my_function()) #will …

Total answers: 1

Printing the number of different numbers in python

Printing the number of different numbers in python Question: I would like to ask a question please regarding printing the number of different numbers in python. for example: Let us say that I have the following list: X = [5, 5, 5] Since here we have only one number, I want to build a code …

Total answers: 3

How to print each element of a list until a certain length Python

How to print each element of a list until a certain length Python Question: How to print each element of my list to a defined length (5), so for example: myList = ["abcdefgh", "ijklmnop"] The output I’m looking for is: abcde ijklm I’ve tried this (printing dates from an excel sheet): i = 2 x …

Total answers: 1