lundi 14 décembre 2015

genereting list from file python

i have a file that looks like this: Pokémon HP Attack_Points Type Weakness Bulbasaur 45 49 Grass Fire Ivysaur 60 62 Grass Fire Venusaur 80 82 Grass Fire . . . and im trying to generate list from a random line and this is my code: from random import randint

open_pokedex=open("pokedex.txt","r")
p1_p1=list()
pokemon_selection=(randint(1,40))
p1_p1.append(open_pokedex.readline()[pokemon_selection])

but this is not working anyone have any ideas?




Aucun commentaire:

Enregistrer un commentaire