Sep-28-2019, 10:25 AM
I have a question, if I have multiple results and wanted to print the results together in the end of the code, what code should I use?
printing multiple results together
|
Sep-28-2019, 10:25 AM
I have a question, if I have multiple results and wanted to print the results together in the end of the code, what code should I use?
Sep-28-2019, 11:19 AM
for example
result1 = "Hello" result2 = "World" print("%s %s" % (result1, result2))
Sep-28-2019, 11:29 AM
Very old, you should not use it, but knowing this formatting syntax is good.
There is much code outside from Python 2 era. result1 = "Hello" result2 = "World" print("%s %s" % (result1, result2))Instead you can use the format method: result1 = "Hello" result2 = "World" print("{} {}".format(result1, result2))Since Python 3.6 the 'f-string': result1 = "Hello" result2 = "World" print(f"{result1} {result2}")or just print the values without formatting a string: result1 = "Hello" result2 = "World" print(result1, result2)
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Sep-29-2019, 02:19 AM
|
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
Search Results Web results Printing the number of days in a given month and year | afefDXCTN | 1 | 2,996 |
Aug-21-2020, 12:20 PM Last Post: DeaD_EyE |
|
Random nr. no repetition & printing multiple lines | Joey | 7 | 3,992 |
Feb-05-2020, 04:23 PM Last Post: Larz60+ |
|
How to append one function1 results to function2 results | SriRajesh | 5 | 4,376 |
Jan-02-2020, 12:11 PM Last Post: Killertjuh |
|
How to execute a string with multiple sqlite statements and print results? | shanepy | 0 | 2,734 |
Nov-20-2018, 10:19 PM Last Post: shanepy |
|
Creating multiple text fies from new url retrieve results | wmc326 | 1 | 3,747 |
Jul-13-2017, 10:57 PM Last Post: Larz60+ |
|
Multiple Question Results code | flynnmackie | 2 | 105,056 |
Mar-13-2017, 06:54 PM Last Post: snippsat |