2014-03-31 90 views
-4

我一直在为一个项目创建一个小游戏的代码,并遇到一个我无法修复的小错误,所以我想知道是否有人可以帮助我。代码需要找到用户输入的两个变量之间的差异,这里是目前的代码;如何在python中找到两个变量的区别3.3.2

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)))] 

现在我需要找到两个变量之间的差异,除以5,它得到的改性剂,然后存储此值,并把它关闭一个球员,加上另一名球员,但我不知道如何。我在网上查找,我似乎找不到任何东西,有没有人可以帮助我呢?

+1

你想哪两个变量之间找到的差异?你试过什么了? – darthbith

+0

我需要做到每个变量的强度和技巧,我到目前为止尝试找到更大的一个,然后把另一个,但由于某种原因它不起作用,我得到一个错误消息 – Charlie1995

+0

“我看了在线我似乎找不到任何东西“ - 我建议寻找”Python 3教程“,例如http://learnpythonthehardway.org/book/ex3.html – TessellatingHeckler

回答

0

将您输入int并丢弃所有这些名单:

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 
相关问题