Ask coding questions

← Back to all posts
Why this program is ignoring this part??
ROCKINGRAYQUAZA

the highlighted portion is not excepted by the the computer Idk why?

maybe there are some syntax issue but I don't know please help me

output is like this but i want that the last list should get its value

Answered by Spacecraft [earned 5 cycles]
View Answer
Voters
ROCKINGRAYQUAZA
Comments
hotnewtop
Spacecraft

Your code is a bit confusing, but I think I see the issue. Line 158 and 159 set fp to '1'. Then, line 167 sets fp to c, which evaluates to "Charmander" from line 161.
From there, your immediate problem is that you didn't capitalize Charmander in your IF statement, causing them to never match:

ROCKINGRAYQUAZA

so what should i do to correct it.. @MarkKohler

ROCKINGRAYQUAZA

but i have given

in my program @MarkKohler

Spacecraft

@ROCKINGRAYQUAZA Yes, but the lowercase of '1' is '1'. Your statement asks to enter the number, not the name. If you follow the lines I highlighted, you will see that you eventually change this input back to "Charmander". Your IF statement on 198 is looking for "charmander" (lower case). If you change this to uppercase, it should work.

ROCKINGRAYQUAZA

bro i just removed the line
fp = fp.lower()
and capatalised the first letter or charmander, bulbasaur and squirtle in my if statements and now the program starts to work
@MarkKohler

ROCKINGRAYQUAZA

what is the logic behind removing
fp = fp.lower() and capatalising first letter can you explain in little bit simple english @MarkKohler

ROCKINGRAYQUAZA

and after that i will mark your answer as the correct one thanks bro you have solved a big problem of mine @MarkKohler

ROCKINGRAYQUAZA

leave it bro i understood the logic thanks ;) @MarkKohler

Spacecraft

@ROCKINGRAYQUAZA fp.lower() would have worked if the input to your question was the name, but you ask to enter the number. So, a number is assigned to fp (either 1, 2, or 3). Then you called fp.lower(), which will convert whatever fp is into lowercase. Since fp is a number, there is nothing to convert.
From there, you change the value of fp again:
line 167 (before your edits) set fp = c, and c = "Charmander" with a capital C, from line 161 (before your edits). All of this bypassed what you thought you were lowering from the fp.lower() command. That brings you back to the IF statement where it is was looking for the lower case charmander, when you had already changed fp back into the uppercase Charmander.

ROCKINGRAYQUAZA

yes bro i understood thanks you I think i should mark this as answer as this is more clear ;) @MarkKohler

ROCKINGRAYQUAZA

i don't want that last list to be empty,please help me @CodingCactus