Monday 23 October 2017

python - How to delete something from a list?

I am trying to write a Suduoku game. Every time I use a
number, I need to delete it from the list.



I
have already tried .pop[1], but it did nothing when the number
was one.



import
random


rownum1 =
["1","2","3","4","5","6","7","8","9"]
print(random.choice(rownum1))

if
random.choice(rownum1) == "1":
del rownum1[0]

print(rownum1)


If one
is randomly selected I expect the output to
be:




["2","3","4","5","6","7","8","9"]


But
nothing is happening when one is randomly chose.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...