-1
import getpass
from art import *
tprint("Hangman")
print("The game is for 2 players")
def guess():
    guess_word = getpass.getpass("What is the word you want guess to him? ")
    chara = print("The choosen word has:\n",len(guess_word),"characters")
    characters = list(guess_word)
    return characters
characters = guess()
for a in characters:
    bjr = print("_")  

when my variable "bjr = print("hello")" the Em dash is like that

how to align "_" like that :

enter image description here

Thanks

Anurag Dabas
  • 23,866
  • 9
  • 21
  • 41
Nathor69
  • 35
  • 4
  • Do you want to *print* or to make a variable full of underscores? Because `bjr = print("_")` prints, then assigns the return value of `print` (`None`) to `bjr`, which makes `bjr` fairly useless. You can print or you can assign, trying to do both at once is a bad idea (it's technically possible in modern Python, but not the way you're doing it, and I'm hesitant to introduce you to it, as it's bad style.). – ShadowRanger Aug 22 '21 at 15:54

1 Answers1

0

Change the last print to print without wrapping Add end='' inside the print().

bjr = print("_", end = '')  

In your case:

import getpass
from art import *
tprint("Hangman")
print("The game is for 2 players")
def guess():
    guess_word = getpass.getpass("What is the word you want guess to him? ")
    chara = print("The choosen word has:\n",len(guess_word),"characters")
    characters = list(guess_word)
    return characters
characters = guess()
for a in characters:
    bjr = print("_", end = '')  

You can change de '' in end= with the font of your choice. The standard one for wrapping is \n which is the one used implicitly when you use print("_")

Piero
  • 404
  • 3
  • 7
  • 22