how do I make the result below print on a single line instead of down the column? Thanks. i = 3 while not i&lt;=0:     i-=1     print(i)  expected: 2 1 0
3114
I'd like to do it in Python. What I'd like to do in this example in C: #include &lt;stdio.h&gt;  int main() {     int i;     for (i=0; i&lt;10; i++) printf(&quot;.&quot;);     return 0; }  Output: ..........  In Python: &gt;&gt;&gt; for i in range(10): print('.') . . . . . . . . . . &gt;&gt;&gt; print('.', '.', '.', '.', '.', '.', '.', '.', '.', '.') . . . . . . . . . .  In Python print will add a \n or space, how can I avoid that? Now, it's just an example, don't tell me I can first build a string then print it. I'd like to know how to &quot;append&quot; strings to stdout.
10087
I'd like to output hello world over 20 characters.  printf "%-20s :\n\n" 'hello world!!'  # Actual output hello world!!        :  # Wanted output hello world!!========:   However, I don't want to complete with spaces but with "=" instead. How do I do that?
271
How do you left pad an int with zeros when converting to a String in java?  I'm basically looking to pad out integers up to 9999 with leading zeros (e.g. 1 = 0001).
96075
Here is a quick question, how to use tex to print this ' symbol? An example is shown below:  data 'a list = Nil | Cons (e, 'a list)   I tried to use ' or `, but they all looks bad.. I am sorry but I am not a native English speaker, so I don't even know the name of '..   Could anyone help me on this simple problem? thank you
61612
I'm looking for a  way to convert numbers to string format, dropping any redundant '.0'   The input data is a mix of floats and strings. Desired output:  0   --> '0'  0.0 --> '0'  0.1 --> '0.1'  1.0 --> '1'  I've come up with the following generator expression, but I wonder if there's a faster way:  (str(i).rstrip('.0') if i else '0' for i in lst)   The truth check is there to prevent 0 from becoming an empty string.  EDIT: The more or less acceptable solution I have for now is this:  ('%d'%i if i == int(i) else '%s'%i for i in lst)   It just seems strange that there is no elegant way to handle this (fairly straightforward) case in python.
1022
The following code works as expected in both Python 2.5 and 3.0:  a, b, c = (1, 2, 3)  print(a, b, c)  def test():     print(a)     print(b)     print(c)    # (A)     #c+=1       # (B) test()   However, when I uncomment line (B), I get an UnboundLocalError: 'c' not assigned at line (A). The values of a and b are printed correctly. This has me completely baffled for two reasons:   Why is there a runtime error thrown at line (A) because of a later statement on line (B)? Why are variables a and b printed as expected, while c raises an error?   The only explanation I can come up with is that a local variable c is created by the assignment c+=1, which takes precedent over the "global" variable c even before the local variable is created. Of course, it doesn't make sense for a variable to "steal" scope before it exists.  Could someone please explain this behavior?
12929
Could someone please tell me what I'm doing wrong with this code? It is just printing 'count' anyway.  I just want a very simple prime generator (nothing fancy).   import math  def main():     count = 3     one = 1     while one == 1:         for x in range(2, int(math.sqrt(count) + 1)):             if count % x == 0:                  continue             if count % x != 0:                 print count          count += 1
26519
I'm pretty sure this is a simple question in regards to formatting but here's what I want to accomplish:  I want to output data onto the screen using cout.  I want to output this in the form of a table format.  What I mean by this is the columns and rows should be properly aligned.  Example:  Test                 1 Test2                2 Iamlongverylongblah  2 Etc                  1   I am only concerned with the individual line so my line to output now (not working) is  cout &lt;&lt; var1 &lt;&lt; "\t\t" &lt;&lt; var2 &lt;&lt; endl;  Which gives me something like:  Test                 1 Test2                  2 Iamlongverylongblah         2 Etc                  1
100007
currently I have a column looks like this:    A B ... 1 A 2 3 4 B 5  6  7 C 8  ...   And I want to make it looks like this    A B ... 1 A 2 A 3 A 4 B 5 B 6 B 7 C 8 C ...   Is there a way to finish the job quickly? Thanks a lot!
35871
How does Python evaluate the expression 1+++2?  How many ever + I put in between, it is printing 3 as the answer. Please can anyone explain this behavior  And for 1--2 it is printing 3 and for 1---2 it is printing -1
77831
I want to print lines from a file backwards without using tac command. Is there any other solution to do such thing with bash?
124264
I have below inputs with huge number of rows  11|ABCD|19900101123123445455|555|AAA|50505050|0000009030 11|ABCD|19900101123123445455|555|AAA|50505050|0000000199 13|ABCD|201803010YYY66666666|600|ETC|20180300|0000084099 11|ABCD|19900101123123445455|555|AAA|50505050|0008995001   And I need to get below output  11|ABCD|19900101123123445455|555|AAA|50505050|9004230 13|ABCD|201803010YYY66666666|600|ETC|20180300|84099   I have been trying with below awk but having too limited knowledge with arrays.  cat test|awk -F"|" '{ a[$1]++;b[$2]++;c[$3]++;d[$4]++;e[$5]++;f[$6]+=$6 }; END { for (i in a); print i, f[i]}'   I need to sum last column of column number 6 and print all first 5 columns, which are separated by pipe and last 6th column as sum of 6th column.
41282
Here's my code:  x = 1.0 y = 100000.0     print x/y   My quotient displays as 1.00000e-05.  Is there any way to suppress scientific notation and make it display as 0.00001? I'm going to use the result as a string.
6626
I have defined a new counter that keeps increasing each time I call the macro that's using it. How can I print the counter value minus one? Something like \value{\theCounter-1} but formatted for text?  MWE  \documentclass{article} \usepackage{parskip} \newcounter{myCount} \setcounter{myCount}{1} \newcommand\newSec[1]{\par\underline{\textsc{newSec}~\themyCount}\hspace{0.5em}{\footnotesize(#1~number)}\stepcounter{myCount}\par}  \begin{document}     \newSec{2}     Some text      \newSec{5}     Here I refer to the counter used before it was incremented: \themyCount. Should print 2.  \end{document}
111324
I declare a variable for a 64 bit counter as :  long long call_count;   What is the format specifier that I should use in print statements?  I tried, %l, %ld, %ll. None seems to be correct.  I use Diab C compiler for compiling my application code to run on pSOS operating system.
100784
I can't seem to grab the month, day and year using   awk '{print $2, $3, $6}' date    Does anyone know how to?
4728
I can output the value of a counter in a LaTeX document via:  \setcounter{mycounter}{1} \arabic{mycounter}   Which inserts a 1. But how do I format the output by, for example, adding a leading zero if mycounter is less than 10 in a way similar to what  lets you do by specifying %02d as your format string?