[Solved] How to rename last letter but not the file ending in python [duplicate]

Do something like this >>> import os >>> for root, subFolders, files in os.walk(‘/tmp’): … for f in files: … if len(f) < 5: continue … newf = f[:-5]+f[-5].lower()+f[-4:] … print “changing”,f,”to”,newf … but looks like you want character before extension instead of 5 char? in that case why not just split the extension from … Read more

[Solved] I am writing a program which adds numbers inputed by the user and then outputting the total. With the total how can i output all the inputed numbers

I am writing a program which adds numbers inputed by the user and then outputting the total. With the total how can i output all the inputed numbers solved I am writing a program which adds numbers inputed by the user and then outputting the total. With the total how can i output all the … Read more

[Solved] How to solve this equation [closed]

You can use sympy, Python’s symbolic math library. from sympy import solve from sympy.abc import C print(solve(1298 + 74.86 * C + 1.283 * C ** 2 – .0078 * C ** 3 – .0006 * C ** 4)) # result: [-28.2719434096994, 62.3383358961427, -23.5331962432216 – 25.9550273611766*I, -23.5331962432216 + 25.9550273611766*I] 0 solved How to solve this … Read more

[Solved] comparing price and quality labtop in list with python

i solved it: number_of_laptops = int(input()) list_of_prices = [] list_of_qualities = [] for i in range(0,number_of_laptops): inp = input() numbers = [] numbers = [int(s) for s in inp.split() if s.isdigit()] list_of_prices.append(numbers[0]) list_of_qualities.append(numbers[1]) def find_better_lp(number_of_laptops): if number_of_laptops == 0: return print(“empty list”) for i in range(0,number_of_laptops): for j in range(0,number_of_laptops): if((list_of_prices[i] <= list_of_prices[j]) and i … Read more

[Solved] What is the issue with this Python code? [duplicate]

When I run your code I get the following exception: TypeError: __init__() takes exactly 3 arguments (1 given) You have to pass x and y arguments to the constructor or define default values: Arguments to the constructor: object1 = a(“name”, “family”) Default values: class a(object): def __init__(self, x=””, y=””): … 12 solved What is the … Read more

[Solved] Python 3.x AttributeError: ‘NoneType’ object has no attribute ‘groupdict’

Regular expression functions in Python return None when the regular expression does not match the given string. So in your case, match is None, so calling match.groupdict() is trying to call a method on nothing. You should check for match first, and then you also don’t need to catch any exception when accessing groupdict(): match … Read more

[Solved] Iterate over list

You need to break up the rows and convert each value to an integer. At the moment you are looking for the presence of the string “3” which is why strings like “2;13” pass the test. Try something like this: list_6 = [“4;99”, “3;4;8;9;14;18”, “2;3;8;12;18”, “2;3;11;18”, “2;3;8;18”, “2;3;4;5;6;7;8;9;11;12;15;16;17;18”, “2;3;4;8;9;10;11;13;18”, “1;3;4;5;6;7;13;16;17”, “2;3;4;5;6;7;8;9;11;12;14;15;18”, “3;11;18”, “2;3;5;8;9;11;12;13;15;16;17;18”, “2;5;11;18”, “1;2;3;4;5;8;9;11;17;18”, … Read more

[Solved] Create list from user input and modify some elements

If you dont want to use list comprehension: my_list=[] for i in range(5): n=int(input(“Enter and integer number:”)) my_list.append(n) print(my_list) for index, i in enumerate(my_list): if i%5==0: my_list[index] = i + 5 print (my_list) 1 solved Create list from user input and modify some elements