Link to home
Start Free TrialLog in
Avatar of catonthecouchproductions
catonthecouchproductionsFlag for United States of America

asked on

Generating # of letters and making them "_"

I am trying to create a hangman program. So far I am trying to generate the number of underscores per word.

EX:

Cat

_ _ _

We have a variable that stores the number of letters in the word and I am trying to generate X amount of _ for each letter in the word.

What would I go about doing that with?

I tried a for loop but that wasn't what I wanted

I have

$lettercount which equals to the number of letters in a word (int)

Just stuck on how I am to make that number of letters in to _

Any suggestions?

Thanks,

Ryan
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
print "_ " x $lettercount;
Avatar of catonthecouchproductions

ASKER

Thank you very much! That worked great. I was lost on how to do that.

Ryan