[Solved] Problem with can only concatenate str (not “NoneType”) to str

The problem is, sizes doesn’t return anything. print does not return values, it just prints. You’d need to do something like: acc = “” for span in Size: acc += span.text.replace(‘EU:’,”).strip() # Concatenate the strings together return acc There are also more efficient ways of doing this using a list comprehension/generator expression and join: return … Read more

[Solved] I need help to understand logic and solve code using python

In your code you are opening the file in with statement, that means it closes automatically. No need to call close() explicitly. For any string manipulation/searching it’s good to know Regular expression (in Python re module). For counting variables you could use Counter from itertools. Here’s an example: from collections import Counter import re with … Read more

[Solved] I have just started learning super basic Python this week. Look at my basic code for entry ticket in a park [closed]

Hi i am also new in Python but as i understand 1- age = “\t\n\tWhat is your age\t\n\t\t\t” 2- input(age) 3- age= int(age) you can change as below age = int(input(“\t\n\tWhat is your age\t\n\t\t\t”)) line means age is a string which containt this data read console and set to age variable try to convert to … Read more

[Solved] Processing dictionary keys in sorted order [closed]

The particular order you’ve mentioned is neither sorted alphabetically nor numerically (by month number). In the dictionary you’ve constructed, the key is the name of the month, and value is the month number. So in order to sort the dictionary by month number i.e. by value (which is what I think you wanted?) you can … Read more

[Solved] The same program again

Try changing: if x >= end: To: if x >= end and y <= end: Also, change: keepgoing == False To: keepgoing = False Also, consider changing: if x == end and y == end: To: if x >= end and y >= end: Note: You should probably use a nested for-loop and cycle through … Read more

[Solved] Why am I getting IndexError: list index out of range? [closed]

This loop is indeed not exceeding the range of the list: for i in range(len(my_list)): Within that loop, you can access list elements using i as the index safely. But that’s not what you’re doing, you’re using hard-coded index values: motMake = motordata.get(‘displayAttributes’)[0][‘value’] or None motModel = motordata.get(‘displayAttributes’)[1][‘value’] or None motYear = motordata.get(‘displayAttributes’)[2][‘value’] or None … Read more