2017-01-19 9 views
-2

のリストに二回登場する要素の声明場合、私は[(2,4)、(4,5)]のような2つの座標のリストを持っています。 1つは10座標で満たされ、もう1つは空です。私は、プレイヤーが入力する座標が配列の場合、コードを設定しています。 'visited'座標を表す空の配列に座標を追加します。私は、「座標」の要素が二回「訪問」一覧に表示されているかどうかをチェックしますif文をしたいです。PythonでPythonの

def corcheck(coordinate,+10locations,+10visits,losecoinslocations,coins): 
    if coordinate in +10locations: 
     coins=coins+10 
     coordinate.append(+10visits) 
     print("+10") 
#  if coordinate in 
    elif coordinate in losecoinslocations: 
     coins=0 
     print("You lose all your coins. -",coins) 
    else: 
     print("This square was empty. Please make your next move.") 
    return +10visits,+10num,losecoinsnum,coins 

要素が、それはlosecoinslocationsに追加されるであろうから、二回+10訪問に表示座標場合チェックがために配置される#ISとeditiedされる行。 + 10locationsに座標が

+2

に対してレンスをチェック ':'無効な構文です! –

+2

'10locations'と' [リスト内のすべての要素が一意であるかどうかのチェック] 10visits'が有効なPython識別子ではありません... – mgilson

+0

はこのの重複を見つけることができない、それは...の –

答えて

0
if len(coordinate) != len(set(coordinate)): 

セットは、重複を除去し、そして元のリスト