How to give a space between 'apple' and 'is ' in a code written in python?

Question:

I have coded Apple is the favorite fruit of SP in python .

But in the output , I got :
Appleis the favorite fruit of SP

Plz help me to identify the mistake and tell me how to add a space between Apple and is.
The code picture link is given below .

The code in python

Asked By: SPzz

||

Answers:

2 easy ways, first your food could be "apple ", or in your string, insert a space before + "is…, so " is….." In either case, you need to add a space.

Answered By: Mike

You can also use "formatted string literals" (a.k.a. "f-strings", available since Python 3.6) to make it easier on yourself:

>>> f"{food} is the favourite fruit of {name}"
apple is the favourite fruit of sp
Answered By: t_krill

You can use format printing here,

hey = "Hello word"
print(hey)
name = "sp"
food = "apple"

print(f"{food} is the favourite food of the {name}")

output

Hello word
apple is the favourite food of the sp
Answered By: Abhishek Kumar
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.