My project


#1



This is my project to help me practice my python skills. I'm making a game mainly composed of strings because I'm not an expert at all. But when I run this code... It DOESNT give any syntax error, the code just doesn't do what I want it to. So when I check if the users input is equal to one of the strings, the list.remove(x) function is working properly. Can anyone explain to me why this happens?


Here is the 1 of 3 of the blocks of code:

if(starter.lower() == "charmander"):
starter_pokemon.remove("Squirttle")
starter_pokemon.remove("Bulbasaur")

When the user inputs the pokemon name in lowercase, it will remove the other 2 from the list (when they put in "charmander" it removes the other 2). But when they put the pokemon in uppercase like so "Charmander" it will print the list (starter_list) and the list didn't have anything removed. Why does the capitalized letter mess with the .remove() function or the if statement. I'm kind of confused, anyways thanks for your time :slight_smile:

from time import sleep

This is the introduction section of the game

print("=============Welcome to 'Pokemon Story Mode'=============")

sleep(1.5)

trainer_name = input("What is your name? ")

If they don't put a name

while len(trainer_name) == 0:
trainer_name = input("What is your name? ")
sleep(1.5)

print("Hello there " + trainer_name + "...")

sleep(3)
print("Welcome to the realm of Pokemon where mystical creatures have abilities to fight others in order to catch them all!")

sleep(7)

Choosing a starter pokemon

starter_pokemon = ["Charmander", "Squirttle", "Bulbasaur"]

print("Here are 3 Pokemon, you may choose 1 only, to start your adventure!")

print("=========================================================")
for print_starters in starter_pokemon:
print(print_starters)
print("=========================================================")

starter = input("Pick your starter Pokemon: ")

sleep(0.5)

Check to see if the user's input is one of the three pokemon

while starter.lower() != "charmander" and starter.lower() != "squirttle" and starter.lower() != "bulbasaur":
print("That's not a Pokemon!")
starter = input("Pick your starter Pokemon: ")

if(starter.lower() == "charmander"):
    starter_pokemon.remove("Squirttle")
    starter_pokemon.remove("Bulbasaur")


elif(starter.lower() == "squirttle"):
    starter_pokemon.remove('Charmander')
    starter_pokemon.remove('Bulbasaur')


elif(starter.lower() == "bulbasaur"):
    starter_pokemon.remove('Charmander')
    starter_pokemon.remove('Squirttle')

print(starter_pokemon)

`


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.