A little messy this.
Import <moudule> always first not inside code.
You call main() 3 times,call main() one time.
if comp_choice != userchoice:
type error.
And the big mistake vegaseat pointet out.
It won't work!
Yes that`s for sure true.
The logic could be better,user only win if 3-3 4-4....
Maybe hightest dice number should win.
So the script without function,with a different print statement.
import random
user_choice = input('Type a number, 1 to 6.\n\n')
comp_choice = random.randint(1,6)
if comp_choice != user_choice:
print 'Computer got %d user had %d | Computer won' % (comp_choice,user_choice)
else:
print 'Computer got %d user had %d | User won' % (comp_choice,user_choice)
Now think off again how to use function for this code.
Here just to give you and idèe off one way to set it upp.
def get_user_choice():
print 'your code'
pass
def check_if_true():
pass
def main():
'''Main menu and info '''
while True:
print 'Welcome to my menu\n'
print '(1) Throw a dice against computer'
print '(2) Nothin yet'
print '(q) Quit'
choice = raw_input('Enter your choice: ')
if choice == '1':
get_user_choice()
elif choice == '2':
pass
elif choice == 'q':
exit()
else:
print 'Not a correct choice:', choice
if __name__ == '__main__':
main()