[Solved] Truble to create a matrix for sudoku in python

Keep looping, know to find 9 different numbers in line = [] import random matrix = [] for i in range(9): line = [] j = 1 while j <= 9: number = random.randint(1, 9) if number not in line: line.append(number) j += 1 matrix.append(line) for i in range(9): print(matrix[i]) 0 solved Truble to create … Read more

[Solved] How to end a python program without it going to the next line of code [duplicate]

while True: choice = input (“Do you want to play?”) if choice == “yes” print(“Great!”) break # Go to the game elif choice == “no” print(“Goodbye.”) break # nothing else: print(“Please answer yes or no.”) solved How to end a python program without it going to the next line of code [duplicate]

[Solved] python error: unsupported operand type(s) for -: ‘str’ and ‘str’ [duplicate]

start_date and stop_date are strings, which don’t support the – operator. If you want to compute their (numerical) difference, define them as integers, i.e. start_date = 20151231171500 stop_date = 20151231174500 or cast them to int: test = int(stop_date) – int(start_date) Caveat: the difference of these numbers would be 3000, not 30. Not sure why you … Read more

[Solved] Python list ways to select objects [duplicate]

Here you go: Z = [[‘A’, ‘B’, ‘C’], [1], [‘x’, ‘y’]] import itertools for element in itertools.product(*Z): print(element) Result: (‘A’, 1, ‘x’) (‘A’, 1, ‘y’) (‘B’, 1, ‘x’) (‘B’, 1, ‘y’) (‘C’, 1, ‘x’) (‘C’, 1, ‘y’) solved Python list ways to select objects [duplicate]

[Solved] python identificare random syntax in text

First, you need to read the text file into a string; find the pattern “{([a-z|]+)}” using regex, split them by “|” to make a list as random words. It could be achieved as the following: import re, random seed = [] matches = re.findall(‘{([a-z|]+)}’, open(‘bio.txt’, ‘r’).read()) [seed.extend(i.split(‘|’)) for i in matches] input = random.choice(seed) solved … Read more

[Solved] Read Excel file which has one of the column as Hyperlink through python

Pandas library does not have the functionality to parse hyperlink as of yet. You could preprocess the excel using libraries such as xlrd or openpxyl to get hyperlinks then use it in pandas. Source: https://stackoverflow.com/a/45446810/7570485 There is also a feature request for this functionality. https://github.com/pandas-dev/pandas/issues/13439 1 solved Read Excel file which has one of the … Read more

[Solved] Can’t uninstall project with no packages

The steps shown in the question will actually create and install a real package. It won’t create any importable files, but it will create metadata in a site-packages directory. Exactly where it has installed depends on your USER_SITE configuration, which you can check with python3.6 -m site, but it’s probably going to be at ~/.local/lib/python3.6/site-packages/example-0.0.0-py3.6.egg-info. … Read more

[Solved] what to fix to solve the TypeError: an integer is required (got type str) [duplicate]

Your error is probably that you forgot to cast the input(…) to int: start_year = input(‘Enter start year’) start_year = int(start_year) you should do the same for end_year and output. Note: It’s really hard to try to help you without the source code. I need to infer a lot of things to help you diagnosis … Read more

[Solved] Why use the object oriented approach in matplotlib for visualizing data? [closed]

As explained in matplotlib blog, the benefits of OO approach are scalability and control. The functional interface (pyplot) was build to reproduce MATLAB’s method of generating figures, which is a very popular propetary programing language in engeenering departments. Pyplot works as a state-based interface, where the states are figures that can be changed by methods. … Read more

[Solved] how to use a while loop in my python code

You could modify the code from the HandlingExceptions – Python Wiki: def collatz(number): if number % 2 == 0: print(number // 2) return number // 2 elif number % 2 == 1: print(3 * number + 1) return 3 * number + 1 has_input_int_number = False while has_input_int_number == False: try: # try to convert … Read more