python 3.x - Simple adding spaces between variables in python3 -
I searched but found many things to remove space, I'm spanking new pythons and writing a simple program I am trying to get the name first, ask the last name and then greeting it. No matter how many spaces I keep between names, on the print function line, it keeps on putting together the first and last names together.
name = input ("what is your first name?:)" Final = input ("what is your last name?") Print ('nice to meet you', name + last ) It outputs:
what's your first name ?: jc
what's your last name?: Jackson <
Good to meet you, Jesse Jackson
desired product There are several ways to get:
focusing the strings
if you want to If you want to focus on the wiki string, you can use the + operator.
It will focus on the way your strings are provided in your code. Example:
& gt; & Gt; & Gt; StringA = 'this one' & gt; & Gt; & Gt; String B = 'test' & gt; & Gt; & Gt; Print (String A + Stringb) 'This is Esther' & gt; & Gt; & Gt; Print (String A + "+ String B)" is a test. Print on the same line Print multiple strings on the same string, so that you can assign your string as a separate code in the form of a print function from a ,
Example:
& gt; & Gt; & Gt; I want to say that this is a test: print ('I want to say:', string A, string b) string format < P> The most commonly used method is string formatting. This can be done in two ways:
- Using the format function - with the example 'old' way % s with example:
& gt; & Gt; & Gt; Format ('format {} example {}' format (string A, string B)) format is an example test & gt; & Gt; & Gt; Print ('Old:% s example of string formatting% s'% (string A, string B)) Old: This is an example test of string formatting Of course these examples can be added Either way you want.
Example:
& gt; & Gt; & Gt; String c = 'normal' & gt; & Gt; & Gt; Print (('% s Strange {} None'% String A) + String C). Format (String B), 'Usage') This is a weird test which is usually
Comments
Post a Comment