Pythonで作業している新しいプログラマ2.7。単純な条件の場合の構文エラー(partychoice = Rの場合)
このコードでは、if 'partychoice = R、' = 'が無効な構文であることを示す行に構文エラーが表示されます。どうしてそれが勝ったのですか?変数を割り当てることはできません。
また、他にもたくさんのエラーがあると確信していますが、私はどこかで始める必要があります。
print "Welcome to 'Pass the Bill', where you will take on the role of a professional lobbyist trying to guide a bill through Congress and get it signed into law by the President!"
start = raw_input(str ('Press Y to continue:'))
print 'Great, lets get started!'
partychoice = raw_input (str("Would you like to be a Republican or Democrat? Type 'R' for Republican or 'D' for Democrat."))
if partychoice = R:
print 'Ah, the Grand old Party of Lincoln and Reagan. Great Choice!'
replegchoice = raw_input (str("What type of bill what you like congress to introduce? Restrictions on abortions, lower income taxes, easier access to automatic weapons, private health plans, or stricter immigration laws? (A = abortion restrictions, L = lower taxes, AW = automatic weapons, H = private health plans, S = stricter immigration laws'))
if replegchoice = A or a
print 'A controversial choice, despite support of most Republicans, you are sure to face opposition from Democrats in Congress!'
if replegchoice = L or l
print 'A popular idea, Republicans in Congress are sure to support this idea, as will many American voters!'
if replegchoice = AW, aw, Aw, or AW
print 'Rural, midwest, and small town voters will love this, as will most Republicans in Congress. Democrats and voters in urban cities will surely be less supportive.'
if replegchoice = H or h
print 'Eimination of Medicare, Medicaid, and Obamacare! Republicans generally like the idea of making each person responsible for paying their own health care costs'
if replegchoice = S or s
print 'a popular idea supported by president Trump, this is sure face strong opposition from democrats and many voters.'
ありがとうございました。
'='の代わりに '=='でなければなりません。つまり、 'partychoice == 'R''の場合、ネストされた' if'sと同じです。 –
タイトルを変更してください。あなたの質問には関係ありません。 – Noorul
他:あなたが新しいプログラマーなら、あなたはPython 3から始めるべきです。 – DSM