r/pythonhelp • u/xlPickleslx • May 31 '22
Why does it print 'none'?
Why does it print 'none' when I start my code?
import random options1 = 1 options2 = [ ["Move"], ["Pillage", "Move", "or Shop"], ["Loot", "Move", "or shop"] ] money = 0 move = 0 loot = [ "Drugs", "Jewels", "Money" ]
def moving(): random.shuffle(options2) if options2[0] == ["Loot", "Move", "or shop"]: ifmav = input(print("What would you like to do? \nWrite "LOOT" to loot nearby chests,\n"MOVE" to move,\nand "SHOP" to check our shop"))
if options1 == 1: options = input(print("What would you like to do?" " Write "MOVE" to move. ")) if options == "MOVE": move += 1 print("You chose to move!") moving()
def find_loot(): random.shuffle(loot) print(loot[0])
2
Upvotes
1
u/kaleidist May 31 '22 edited May 31 '22
So this is your code when I format it:
To answer your question technically, the reason it prints "None" is because
input()takes a positional argument which it prints. So when you putprint(...)inside ofinput(), that calls the print() method twice. It prints the positional arguments forprint()but also prints whatever the print method itself returns. The print method itself returnsNone. So you end up printing both the string you have insideprint(...)andNone. The solution you want is to leave out theprint(), such as:That will print just that string and then take user input.
There are some other issues with your code, but hopefully this gets you on your way.