catonthecouchproductions
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
print "_ " x $lettercount;
ASKER
Thank you very much! That worked great. I was lost on how to do that.
Ryan
Ryan