C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD

# how to convert my list output into int outputs in python

By : Geri Pavlova
Date : November 19 2020, 03:59 PM
I hope this helps .
code :
``````\$ python test.py
Enter the limit of your matrix:3
Enter the element:1
Enter the element:2
Enter the element:3
Enter the element:1
Enter the element:2
Enter the element:3
Enter the element:1
Traceback (most recent call last):
File "test.py", line 209, in <module>
a[i][j]=int(input("Enter the element:"))
IndexError: list index out of range
``````
``````a=[[random.random()for i in range(n)],[random.random()for j in range(n)]]
``````
``````[[0.9632434262652646, 0.7470504655963679, 0.2750109619917276], [0.7032133906246875, 0.16200573351318048, 0.09565026547688305]]
``````
``````n = int(raw_input("Enter the limit of your matrix:"))
a = []
tmp = [0 for k in range(n)]
for i in range(0,n):
a.append(list(tmp))
for j in range(0,n):
a[i][j] = int(input("Enter the element:"))

sumr = sum(map(lambda x:sum(x), a))
sumc = 0
for j in range(0,n):
sumc +=sum(map(lambda x:x[j], a))

print sumr
print sumc
``````
``````Enter the limit of your matrix:3
Enter the element:1
Enter the element:2
Enter the element:3
Enter the element:1
Enter the element:2
Enter the element:3
Enter the element:1
Enter the element:2
Enter the element:3
18
18
``````

Share :

## How to convert a for loop output into a list (python)

By : Someone
Date : March 29 2020, 07:55 AM
wish helps you The easiest way for your understanding, without using list comprehension, is:
code :
``````mylist = []
for y,x in zip(range(0,4,1),range(0,8,2)):
mylist.append(str(x+y))
print mylist
``````
``````['0','3','6','9']
``````

## Can any anyone help to convert multiple scalar outputs into a vector output?

By : Owais Khan
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , For a situation like this:
code :
``````X(3) = 0;
for i = 1:3
X(i) = 4*i;
end
``````

## How to convert a for loop output into a python list

By : Marius Perde
Date : March 29 2020, 07:55 AM
this one helps. I'm new to Python, sorry for the level of this question.
code :
``````lista = []

for price_list_items in price_list:
for values in price_list_items:
x= values.rstrip(' zł')
lsita.append(x)

lista = ['479 000', '350 000']
for idx, item in enumerate(lista):
item = item.split()
item = ''.join(item)
lista[idx] = int(item)

print(lista)
``````
``````lista = ['479 000', '350 000']
lista = list(map(lambda x: int(''.join((x.split()))), lista))
``````

## Convert the output of ls in a python list

By : user3080709
Date : March 29 2020, 07:55 AM
code :
``````import os
files = os.listdir()
``````

## How to convert an SQL Output to a python list

By : Caio
Date : March 29 2020, 07:55 AM
I hope this helps you . It is minimal example which create database with two elements and later it uses data from database to fill Treeview
You have to use create() only once.
code :
``````import tkinter as tk
from tkinter import ttk
import sqlite3

def create(con):
cur = con.cursor()

cur.execute('''CREATE TABLE IF NOT EXISTS  user (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age TEXT NOT NULL,
email TEXT NOT NULL UNIQUE,
town TEXT NOT NULL
);''')

cur.execute('INSERT INTO user (name, age, email, town) values("James Bond", 45, "bond@mi6.uk", "London")')
cur.execute('INSERT INTO user (name, age, email, town) values("Rambo", 45, "rambo@usa.com", "Washington")')

con.commit()

# --- main ---

con = sqlite3.connect("user_info.db")
cur = con.cursor()

create(con)

root = tk.Tk()

tv = ttk.Treeview(root)
tv.pack(fill='both', expand=True)
tv.config(columns= ("name", 'age', 'email', 'town'))

tv.column('#0', width = 100)

tv.column('1', width = 100)

tv.column('name', width = 100)

tv.column("2", width = 100)

tv.column("3", width = 100)

cur.execute('SELECT * FROM user')
for number, row in enumerate(cur.fetchall()):
print(row)
item = 'item{}'.format(number)
tv.insert("", 'end', item, text=row[0])
tv.set(item, 'name', row[1])
tv.set(item, 'age', row[2])
tv.set(item, 'email', row[3])
tv.set(item, 'town', row[4])

root.mainloop()
``````