About 50 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. 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": …

  3. 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 …

  4. python - How to print the words in a string - Stack Overflow

    Mar 19, 2019 · I want to do the following in my code: Print each words of a string in a new line Print each character in a new line I have been able to achieve the second part using the following code: s2 = "I...

  5. How to print formatted string in Python3? - Stack Overflow

    Both make it easier to not get confused about where print() starts and ends and where the formatting takes place. In both f-strings and str.format(), use !r after the field to get the repr() output, just like %r …

  6. 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 ...

  7. python - how to print a list like a string? - Stack Overflow

    Mar 24, 2018 · 3 You should use the join() method, in python, join() returns a string in which the string elements of sequence have been joined by str separator.

  8. Python: print specific character from string - Stack Overflow

    Jan 31, 2016 · How do I print a specific character from a string in Python? I am still learning and now trying to make a hangman like program. The idea is that the user enters one character, and if it is in …

  9. python - Print "\n" or newline characters as part of the output on ...

    Jul 25, 2015 · 114 I'm running Python on terminal Given a string string = "abcd\n" I'd like to print it somehow so that the newline characters '\n' in abcd\n would be visible rather than go to the next line …

  10. How can I print bold text in Python? - Stack Overflow

    Jan 19, 2012 · In Python 3 you can alternatively use cprint as a drop-in replacement for the built-in print, with the optional second parameter for colors or the attrs parameter for bold (and other attributes …