[Solved] List comprehension example I don’t understand [closed]

Your code is using Python’s list comprehension to create a list from another list based on the condition. See more about list comprehensions here: https://www.programiz.com/python-programming/list-comprehension The [1] is accessing the item at index 1 (2nd item) of your sorted list. As for .join, each line in the sorted list is being printed out with a … Read more

[Solved] Python-Add or remove letters at a specific location

You should do the following: generate a string containing all the letters use ranodm.sample() instead of random.choice() to generate a list of 3 random letters, which you then should join() return an in-place list with the new elements It’d look like this: import string import random def add_str(lst): _letters = string.ascii_letters return [”.join(random.sample(set(_letters), 3)) + … Read more

[Solved] The for loop doesn’t loop even when the answer is not right [closed]

The for loop actually does loop, it just does do anything unless the answer is correct. you want: while enter!=”off”: if enter == “1”: prefer= input(“enter your preference”) if prefer ==”sports”: print(“Hardcore Sports Podcast”) enter = input(‘Enter 1 – recommendation, 2 – draw, off – exit’) else: print(“Kanye West’s new album”) enter = input(‘Enter 1 … Read more

[Solved] I run the following code and expect to get all the words from the link below in a list without repeating any word. How determine if a word is unique?

I run the following code and expect to get all the words from the link below in a list without repeating any word. How determine if a word is unique? solved I run the following code and expect to get all the words from the link below in a list without repeating any word. How … Read more

[Solved] TypeError: unsupported operand type(s) for &: ‘str’ and ‘int’ on compile re [closed]

You are calling the re.compile() function, whose second argument is an integer representing the different regular expression flags (such as IGNORECASE or VERBOSE). Judging by your variable names, I think you wanted to use the re.findall() function instead: findall_localizacao_tema = re.findall( ‘:.? (*)’ + findall_tema[0] + “https://stackoverflow.com/”, arquivo_salva) You can still use re.compile, but then … Read more