Skip to content
← Back to Community
Is it possible to display a username?
Profile icon
OlauPla

So I want that in python when they run the code it will print the username

Answered by RYANTADIPARTHI [earned 5 cycles]
View Answer
Voters
Profile icon
OlauPla
Comments
hotnewtop
Profile icon
RYANTADIPARTHI

Do you mean they're real repl.it username? or normal?. If it's normal, then just do this:

username = input("username ? ") print(username)
Profile icon
OlauPla

@RYANTADIPARTHI repl.it username

Profile icon
OlauPla

@RYANTADIPARTHI like

os.environ['REPL_OWMER']
Profile icon
RYANTADIPARTHI

@OlauPla then if you know, won't that work?

Profile icon
OlauPla

@RYANTADIPARTHI I want the username not the owner

Profile icon
RYANTADIPARTHI

@OlauPla i don't think you can get that.

Profile icon
OlauPla

@RYANTADIPARTHI oh thanks

Profile icon
RYANTADIPARTHI
Profile icon
programmeruser

@OlauPla REPL_OWNER returns the user who's running the program, you can test it.

Profile icon
OlauPla

@programmeruser oh thanks!

Profile icon
OlauPla
Profile icon
EpicJohn127

use this:
from os import environ

username = os.environ['REPL_OWNER']
print("Hello, " + username)

That should show it

Profile icon
Coder100

Well you can, only if you like add repl auth
read this

Profile icon
Cooolcoder

maybe repl has an api so you can get data from there?
there may be a function where: print("*the username they want to print")

or maybe you can ask users for their username like this:

username = input("What is your username?")
print (username)
return 0

Profile icon
Wumi4

Maybe using web scraping to scrape the username data, then print all of them I guess.

Profile icon
MicroSoftHelp

@OlauPla https://realpython.com/python-print/ was a link that I found helpful! I hope this helps you!

Profile icon
OlauPla

@OperationDemon yeah that is no help is like leaving me in the woods and giving me a flashlight

Profile icon
MicroSoftHelp

@OlauPla ohh i thought u needed help with the print command.