2017-05-14 13 views
-4

これは私のコードです:Python 3.x - 2つの三角形の2つの辺が平行かどうかをユーザーに入力する方法を教えてください。

shape= 'Triangle' 
name_1='ABC' 
name_2='DEF' 
Yes= 'Yes' 
No= 'No' 

if shape == 'Triangle': 
    parallel= input("Is there two parallel sides in", shape+"s", name_1," and", name_2,"? Please Enter Yes or No: ") 
    while parallel != Yes and parallel != No: 
     print("Please Enter Yes or No.") 
     parallel= input("Is there two parallel sides in", shape+"s", name_1," and", name_2,"? Please Enter Yes or No: ") 
    if parallel == Yes: 
     ParallelSides_1= input("Please Enter the 1st parallel side. E.G. AB. Input: ") 
     while ParallelSides_1 not in name_1 and ParallelSides_1 not in name_2: 
      print("This side does not belong to", shape+"s", name_1,"and", name_2) 
     ParallelSides_2= input("Please Enter the 2nd parallel side. E.G. EF. Input: ") 
     if ParallelSides_1 in name_1: 
      while ParallelSides_2 not in name_2: 
       print("This side does not belong to", shape, name_2) 
       ParallelSides_2= input("Please Enter the 2nd parallel side. E.G. EF. Input: ") 
     if ParallelSides_1 in name_2: 
      while ParallelSides_2 not in name_1: 
       print("This side does not belong to", shape, name_1) 
       ParallelSides_2= input("Please Enter the 2nd parallel side. E.G. EF. Input: ") 

    print(ParallelSides_1,"and", ParallelSides_2,"are parallel.") 

私の問題は、私はこのコードを実行するこれまでのときに私はエラーの多くを得ることです。私はそれらを修正する方法を知らない。エラーの一つは次のとおりです。

line 8, in parallel= input("Is there two parallel sides in", shape+"s", name_1," and", name_2,"? Please Enter Yes or No: ") TypeError: input expected at most 1 arguments, got 6

私はこのコードが何をしたいかは、両方の三角形で平行線があるかどうかを確認し、それらが第一の三角形(NAME_1)と第二の三角形に属しているかどうかを確認することです。

+1

を多分あなたはエラーが何であるかを私たちに伝えることができますか? 'Yes'と' No'は変数ではありません。それは最初のエラーだろう... –

+0

ありがとう。私はそれを修正しましたが、私はまだこのエラーを受け取ります:ライン8、 パラレル=入力( "シェイプ+" s "、name_1、"、name_2 " ") TypeError:入力が最大で1つの引数が6つあります。 –

+1

文字列を結合するためにコンマを使用しません。入力関数は1つの文字列しか受け取りません。 –

答えて

0

ライン8と11 "+" と "" 置き換え:

parallel= input("Is there two parallel sides in " + shape + "s" + name_1 + " and " + name_2 + "? Please Enter Yes or No: ") 
関連する問題