I am trying to iterate a list and then save it to a file .txt with open/write .
lista = ['uno', 'dos', 'tres']
mi_path = "../fichero.txt"
f = open(mi_path, 'a+')
for i in lista:
f.write(i)
f.close()
I give the attribut...
This is my code, which I run in Python 2.7.13:
print "hola"
hiola = input()
if hiola == salsa:
print "hola"
And the error that throws me is the following:
Traceback (most recent call last):
File "C:\Programacion\Python\hola.py", li...
Someone can help me because and how it works in python because I try to do it according to the documentation and it gives me different results
import operator
operator.or_(2,8)
10
operator.or_(8,2)
10
8 | 2
10
2 | 8
10
2 or 8
2
2 | 8
10...
Hi, I'm trying to make a code using the Eratosthenes Screen method but I get confused in the part of multiplying and eliminating the number that is not prime, the teacher says we should use a del or something to eliminate the number what is in t...
I'm trying to make a bash adaptation (the Linux terminal) in Windows, for this I'm using Python.
#-*- coding: utf-8 -*-
import subprocess
import os
if __name__ == '__main__':
wt = True
while wt:
cmd = str(raw_input("{}>".for...
I am doing a project for the school in which I have to program software that helps children improve their spelling:
#-*- coding: utf-8 -*-
import random
import subprocess
def corrector(pbien, tup):
if tup == pbien:
return 1
e...
Since some time ago I am trying to make a bash simulator using python, I am creating the tail and head commands, for this create 2 functions:
def head(textfile):
content = []
try:
file = open(textfile, "r")
for line in...
I am trying to solve an exercise that I think is quite simple, given a list, print all the possible combinations / permutations of x elements. That is, take out all possible combinations but give a filter for the results.
At the moment I have...
I must make a pyramid that something like this
n = 5
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
but what I try to do gives me that way
number n: 6
0 1 2 3 4 5 0
1 2 3 4 5 1
2 3 4 5 2
3 4 5 3
4 5 4
5 5
6
this is the code
nu...