About 854,000 results
Open links in new tab
  1. printing - Print variable and a string in python - Stack Overflow

    If the Python version you installed is 3.6.1, you can print strings and a variable through a single line of code. For example the first string is "I have", the second string is "US Dollars" and the variable …

  2. How can I print variable and string on same line in Python?

    I am using python to work out how many children would be born in 5 years if a child was born every 7 seconds. The problem is on my last line. How do I get a variable to work when I'm printing text ...

  3. python - How do I put a variable’s value inside a string (interpolate ...

    The built-in print function accepts a variable number of arguments, and can take in any object and stringify it using str. Before trying string formatting, consider whether simply passing multiple …

  4. python - How can I print multiple things (fixed text and/or variable ...

    I want it to print out Total score for Alice is 100, but instead I get Total score for %s is %s Alice 100. How can I get everything to print in the right order with the right formatting? See also: How can I print …

  5. python - Print a variable's name and value - Stack Overflow

    print x # easy to type, but no context print 'x=',x # more context, harder to type 12 x= 12 How can write a function that will take a variable or name of a variable and print its name and value? I'm interested …

  6. python - Print Combining Strings and Numbers - Stack Overflow

    Aug 18, 2012 · To print strings and numbers in Python, is there any other way than doing something like: first = 10 second = 20 print "First number is %(first)d and second number is %(second)d" % {"first": …

  7. python - Concatenating values in a print statement - Stack Overflow

    Sep 10, 2016 · print "Hello ", name Notice the missing parentheses. print isn't a function that's called, it's a statement. It prints Hello Bob because the first string is and the variable separated by the comma is …

  8. python - Print raw string from variable? (not getting the answers ...

    I have my variable assigned to big complex pattern string for using with re module and it is concatenated with few other strings and in the end I want to print it then copy and check on regex101.com.

  9. How to print variable inside quotation marks? - Stack Overflow

    print repr(str(variable)) Otherwise, prefer the .format method over the % operator (see Hackaholic's answer). The % operator (see Bhargav Rao's answer) also works, even in Python 3 so far, but is …

  10. python - How to assign print output to a variable? - Stack Overflow

    The print statement in Python converts its arguments to strings, and outputs those strings to stdout. To save the string to a variable instead, only convert it to a string: