[Solved] How do i print out number variables in python 3? [closed]

The main problem here is that you are calling functions as they were variables Here is your code with the functions being called correctly: import math print(‘input your height and weight to find BMI.’) num_a = int(input(“feet==”)) num_b = int(input(“inches==”)) num_c = int(input(“weight(lbs)==”)) def weight(): return int(num_c) * 2.2 def height(): return (int(num_a)) * 12 … Read more

[Solved] Locate all similar “touching” elements in a 2D Array (Python) [closed]

You might consider learning how to implement breadth-first searches and depth-first searches in order to accomplish your objective. The following example shows how both of these search strategies can be easily handled in one function. A modular approach should make the code simple to change. #! /usr/bin/env python3 from collections import deque from operator import … Read more

[Solved] Python – How to replace adjacent list elements with a different value

And yes , you can just pass with if/else and for loops : a = [[0,0,0,0,0], [0,1,1,0,0], [0,1,0,1,0], [0,0,1,0,0], [0,0,0,0,0]] to_replace = 1 replacement = 9 for i in range(len(a)): for x in range(len(a[i])): if a[i][x] == to_replace: for pos_x in range(i-1,i+2): for pos_y in range(x-1,x+2): try: if a[pos_x][pos_y] != to_replace: a[pos_x][pos_y] = replacement except … Read more

[Solved] I need help!!! error with input in sqlite3, I’m new to this [closed]

The problem is the way you’re building your query string. String values need to be wrapped in single quotes, otherwise they will be interpreted as DB objects (table name, column name, …). strConsulta= “insert into tabla(nombre,autor,year) values (‘”+nombre1+”‘,'”+autor1+”‘,”+year1+”)” You can avoid this issue by using parameterized queries: params = [nombre1, autor1, year1] strConsulta= “insert into … Read more

[Solved] rearding regex (python) [closed]

Here: http://rubular.com/r/CCW7sAUMrs is an example regex that matches whole text within {{ }}. You can easily clean up Your string with it using re.sub. Note, that it will not work when You have text like {{test}} paragraph {{test}}, because it will match whole string. As larsmans said, it gets harder if You can nest braces. … Read more

[Solved] How to replace specific part of a string (replace() dosen’t help…) [closed]

I just got a trick for you to achieving what you want. a = “hello world, hello there, hello python” a = a.replace(“hello”,”hi”,2).replace(“hi”,”hello”,1) print(a) So what exactly 2nd Line does it it is replacing first two occurrence of hello to hi and then replacing 1st occurrence of hi to hello. Thus getting the output you … Read more