minus-squarehapaxlegomina@artemis.camptoProgramming@programming.dev•need help with some fundamentals of for loops. it looks like im so close to fully grasping grabbing an item out of a list, but not quite. examples belowlinkfedilinkarrow-up6arrow-down1·1 year agoDon’t forget Python’s amazing list comprehension syntax! guess = input(“Guess a letter:”).lower() display = [ letter if letter == guess else “_” for letter in word ] Just one part of your question, but it saves a lot of futzing around with indices and replaces. linkfedilink
Don’t forget Python’s amazing list comprehension syntax!
guess = input(“Guess a letter:”).lower() display = [ letter if letter == guess else “_” for letter in word ]
Just one part of your question, but it saves a lot of futzing around with indices and
replace
s.