2014-03-31 3 views
-4

프로젝트 용 작은 게임을위한 코드를 작성하고 해결할 수없는 작은 오류가 발생하여 누군가 도움을 줄 수 있는지 궁금합니다. 나를. 코드는 사용자가 입력 한 두 변수 사이의 차이점을 찾아야합니다. 여기까지 코드가 있습니다.파이썬에서 두 변수의 차이점을 찾는 방법 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

"나는 온라인으로 보았다. 그리고 나는 아무것도 찾을 수 없을 것 "- 나는 파이썬 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 
관련 문제