-4

I have been creating code for a small game for a project and have run into a small error which I can't fix, so I was wondering whether someone can help me. The code needs to find the differences between two variables input by the user, here is the code so far;

import random

print('Welcome to the game')
char1=[input('What is the fist characters name: ')]
char2=[input('What is the second characters name: ')]
char1st=[input('What is the strength of '+(str(char1)))]
char1sk=[input('What is the skill of '+(str(char1)))]
char2st=[input('What is the strength of '+(str(char2)))]
char2sk=[input('What is the skill of '+(str(char2)))]

Now I need to find the difference between the two variables and divide it by 5 to get a modifier, then store this value and take it off one player and add to another player, but I do not know how. I have looked online and I cant seem to find anything so is there anyone who can help me with this?

darthbith
  • 18,484
  • 9
  • 60
  • 76
Charlie1995
  • 29
  • 1
  • 7
  • 1
    Which two variables would you like to find the difference between? What have you tried so far? – darthbith Mar 31 '14 at 17:20
  • i need to do it to each variable strength and skill, i have so far tried by finding the larger one and then taking the other away but for some reason it doesn't work and i get an error message – Charlie1995 Mar 31 '14 at 17:31
  • "I have looked online and I cant seem to find anything" - I suggest looking for 'Python 3 tutorial', e.g. http://learnpythonthehardway.org/book/ex3.html – TessellatingHeckler Mar 31 '14 at 17:37

1 Answers1

0

Convert your input to int and drop all those lists:

print('Welcome to the game')
char1=input('What is the fist characters name: ')
char2=input('What is the second characters name: ')
char1st=int(input('What is the strength of '+char1))
char1sk=int(input('What is the skill of '+char1))
char2st=int(input('What is the strength of '+char2))
char2sk=int(input('What is the skill of '+char2))

strmod = abs (char2st - char1st) / 5 # or // 5 for floor division
#and so on
Hyperboreus
  • 31,997
  • 9
  • 47
  • 87