Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
1

does anyone know how to make it print a sentence with persons name in it

yomicroyeewww
yomicroyeewww

i want to make it orint a persons name with a sentence in it

2 years ago
You are viewing a single comment. View All
6
RYANTADIPARTHI
RYANTADIPARTHI

Solution

There are multiple ways to do it. here are some of them:

  • 1st one is the normal print with a ,
import time print('welcome young fellow replers how are you guys today?') name = input() print('ok', name) time.sleep(1) print('it is nice to meet you.')
  • 2nd way is formatting it:
import time print('welcome young fellow replers how are you guys today?') name = input() print("nice {}".format(name)) time.sleep(1) print('it is nice to meet you.')

IT can be used in multiple variables

import time print('welcome young fellow replers how are you guys today?') name = input() print("nice {}, this is cool {}".format(name, name)) time.sleep(1) print('it is nice to meet you.')
  • 3rd, f This is in more advanced versions of python, and is advanced of format.
import time print('welcome young fellow replers how are you guys today?') name = input() print(f"Cool {name}") time.sleep(1) print('it is nice to meet you.')

You just have to use a {} and put f before the string

  • 4th is the %s
import time print('welcome young fellow replers how are you guys today?') name = input() print("nice %s", %(name)) time.sleep(1) print('it is nice to meet you.')
  • and the + for this, put spaces, to look good
import time print('welcome young fellow replers how are you guys today?') name = input() print("cool " + name) time.sleep(1) print('it is nice to meet you.')

I put an extra space before it, so it would not be concatenated close together.


Well that's it. You can use either of them, but the most easiest way is just a ,. It's more viable. But it's your choice. any of them work.

2 years ago