My code:
name=input('What is your name?')
print('So you call yourself \'',name,"' huh?")
My output
What is your name?lll
So you call yourself ' lll ' huh?
Need to get rid of the space between lll and apostrophes
My code:
name=input('What is your name?')
print('So you call yourself \'',name,"' huh?")
My output
What is your name?lll
So you call yourself ' lll ' huh?
Need to get rid of the space between lll and apostrophes
f-Strings
are new and Improved Way to Format Strings in Python and you can use these to get your desired output like this:
print(f'So you call yourself "{name}" huh?')
print(f"So you call yourself '{name}' huh?")
Output:
So you call yourself "Raja Norhuda Adnan" huh?
So you call yourself 'Raja Norhuda Adnan' huh?
There are many ways to make this:
First one using % operator
name = "Alex"
print('So you call yourself "%s" huh?' % name)
Second using format
name = "Alex"
print('So you call yourself "{}" huh?'.format(name))
print('So you call yourself "{name}" huh?'.format(name=name))
Using f-string (works only in Python 3.6)
name = "Alex"
print(f'So you call yourself "{name}" huh?')
In all 3 cases result will be the same.
You can even go further and do something like this
print('So you call yourself "#name#" huh?'.replace('#name#', name))
If you worried about performance you can check this question
A trick is to mix quotes:
name = 'foo'
print(f"So you call yourself '{name}' huh?")
"
around the complete string
'
around the item