'Is it possible to wrap multiple print commands that contain, strings, variables, and integers, to a variable that can later be written to a file
#attempt to print the contents individually-FAILED
cut=(
('total genes',Signature_1, str(len(NameA))),
('up genes',Signature_1, str(len(upA))))
for i in cut:
print(i)
#actual output=('total genes', 'V.txt', '3725')
#desired output=total genes V.txt 3725
#example of multiple print commands I would like to execute and write to a file
print('down genes',Signature_1,len(downA)),
print('total genes',Signature_2, len(NameB)),
print('up genes',Signature_2,len(upB)),
Attempting to combine multiple print statements under a single variable and execute a for loop to print each line within that variable. Ultimately, I am doing this in order to write the output to a .txt file. sys.stdout does perform desired function, but the block acts like a recursive loop and never terminates, looking for alternatives. So far my only ideas are to group each text under one variable and execute a for loop (this has failed). My second approach was to group the multiple print methods under a variable and execute each from the variable level (also failed & and not sure if possible). Any alternatives or suggestions would be appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
