Skip to content
Advertisement

Make a for loop that doesn’t add a new line (Class’s List)

I’m pretty new to python and I’m trying to make an inventory for a text RPG game I’m making if you could help me figure this out id super appreciate it!

JavaScript

Current output if I enter Test as name then, giveX3, stats

JavaScript

Desired output if I enter Test as name then, giveX8, stats Also would like to do a new line after every 4 Items have been shown

JavaScript

If you have any suggestions I’d really appreciate the help! P.S it does not have to be a for loop but I do not want to have to print every weapon index in order to get them in that output

Advertisement

Answer

You can use slicing and join:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement