Jan-30-2021, 02:12 AM
Hi,
I want to create a loop that would attach the ids from a certain dictionary to a string, space between ids.
Why? Thank you
I want to create a loop that would attach the ids from a certain dictionary to a string, space between ids.
import string letters = list(string.ascii_lowercase) dic = {} lista = [] strin=() final=[] for id, i in enumerate(letters): dic[id]=i def alphabet_position(text): for i in text: strin=' '.join([str(k+1)+v for k,v in dic.items() if v == i.lower()])But the 'strin' returned is empty. It works fine when I remove the condition in the list comprehension (if v==i.lower())).
Why? Thank you