Very much a beginner but trying not to look up too many tutorials and problem solve myself...
So I tried to make rock paper scissors as my first 'proper project' and I'm stuck trying to get the computer to pick a random answer.
After a bit of googling I came across the 'randrange' function but I've never seen it and don't understand how it works:
print('Rock paper scissors')
choice = input('Choose: ')
comp_choice = ['rock', 'paper', 'scissors']
comp_choice.randrange(0, 2)
'rock' > 'scissors'
'scissors' > 'paper'
'paper' > 'rock'
if choice > comp_choice:
print('You win!')
else: print('You loose...')
Output after entering input for choice variable:
line 4, comp_choice.randrange(0, 2)
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'randrange'
If anyone could give me a solution would be appreciated ๐ (also anyway to make the whole thing smaller/tidier if you're feeling extra nice) thanks