Python Forum
Unexpected input within an if/elif statement
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unexpected input within an if/elif statement
#1
While trying to implement a simple if/elif statement, I'm getting an assault of errors that I don't understand. Hopefully, you will read my code and tell me what I'm doing wrong, I think I'm missing something basic. I have a function called "Stats" that displays the user's stats. By choosing an advantage that user can upgrade one of the three stats (health, power, luck).
if advantage == 1:
    BaseHealth = 150
Stats()

elif advantage = 2:
BaseLuck = 150
Stats()

elif advantage == 3:
BasePower = 150
Stats()
Thanks for your time
Reply
#2
The indentation is wrong.
if advantage == 1:
    BaseHealth = 150
    Stats()
 
elif advantage = 2:
    BaseLuck = 150
    Stats()
 
elif advantage == 3:
    BasePower = 150
    Stats()
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
(May-12-2018, 03:47 AM)fier259 Wrote: I'm getting an assault of errors that I don't understand.
Please, always post the entire traceback that you get. We need to see thе whole thing.
Take a time to read What to include in a post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question If, elif, and else statement not working PickleScripts 3 883 Mar-30-2023, 02:53 PM
Last Post: PickleScripts
  Error in Using INPUT statement gunwaba 1 2,068 Jul-03-2022, 10:22 PM
Last Post: deanhystad
  If elif else statement not functioning SamDiggityDog 4 2,645 Jun-03-2020, 12:27 AM
Last Post: SamDiggityDog
  Proper use of if..elif..else statement nick1941 2 2,401 Mar-06-2020, 11:22 PM
Last Post: nick1941
  Using Input() in If...Elif Statements Shemira 11 7,835 Nov-24-2019, 06:57 AM
Last Post: perfringo
  Syntax Error (elif statement) Kanashi 0 3,660 Nov-20-2019, 11:29 PM
Last Post: Kanashi
  If Else Statement with User Input CalPark16 1 2,654 Sep-19-2019, 06:54 PM
Last Post: Axel_Erfurt
  Unexpected output: if statement CabbageMan 1 1,760 Sep-04-2019, 04:12 PM
Last Post: ThomasL
  Whats the right way to refactor this Big if/elif/elif ? pitosalas 1 2,237 Jul-28-2019, 05:52 PM
Last Post: ichabod801
  Problem with elif statement Haddal99 2 2,268 May-20-2019, 09:26 AM
Last Post: avorane

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020