Skip to content
Advertisement

Tag: loops

Output is an empty file

My code does not throw an error, it simply creates the files, but of which are empty. I tried it from the command line, and it works using the wildcard training_set_pssm/*.pssm path, but I must do it from the IDE because it is not printing the correct output anyway. The input file is a set of checkpoint files that look

Compare all elements of a list

To illustrate my problem, imagine I have a list and I want to compare each element with the next one to check if they are the same value. The problem is that when I try to access the last element of the list and compare it with “the next one”, that one is out of range, so I would get

For loops and conditionals in Python

I am new to Python and I was wondering if there was a way I could shorten/optimise the below loops: I tried this oneliner, but it doesn’t seem to work: Answer You can use itertools.product to handle the nested loops for you, and I think (although I’m not sure because I can’t see your data) you can skip all the

How is print(‘r’) or print(‘ ‘) giving me the output?

We were asked to print the following output: I understand that it would require two loops so I tired this: With this I am getting the desired output, but as soon as I remove the last line of print(‘r’) the output becomes something like this: The desired output also comes out when I used print(‘ ‘) instead of print(‘r’), I

Advertisement