I have been searching for various alternatives but I am not able to sort the array from least to greatest without sort(). How can I detect?
serie = [4,3,2,1,6,8,7]
for i in serie:
if i > 0:
i = i - 1
print(i)
I have been searching for various alternatives but I am not able to sort the array from least to greatest without sort(). How can I detect?
serie = [4,3,2,1,6,8,7]
for i in serie:
if i > 0:
i = i - 1
print(i)
I'm learning how to use buttons in Swift and I'm changing the color of several of them separately when they are pressed. The problem is that when I press the second button the first one also changes color, and I find it somewhat strange since in theory they are two different functions and one should not affect the other. Anyone know what might be happening?
//
// ViewController.swift
// EjemploProyecto
//
// Created by Mario Miranda on 17/4/22.
//
import UIKit
class ViewController: UIViewController {
//Outlets
@IBOutlet weak var myButton: UIButton!
@IBOutlet weak var button2: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
//Buttons
myButton.backgroundColor = .green
button2.backgroundColor = .blue
}
@IBAction func buttonAction(_ sender: Any) {
if myButton.backgroundColor == .green
{
myButton.backgroundColor = .blue
} else
{
myButton.backgroundColor = .green
}
}
@IBAction func buttonAction2(_ sender: Any) {
if button2.backgroundColor == .blue
{
button2.backgroundColor = .gray
} else
{
button2.backgroundColor = .blue
}
}
}
I am using some very simple conditionals and it gives me the following error:
unary operator cannot be separated from its operand.
import Foundation
import UIKit
//SENTENCIAS IF
let myNumber = 5
//Una barra invertida y los paréntesis lo que aparece es la variable
//siempre y cuando tengamos un texto
if myNumber >= 5 && <= 10
{
print("\(myNumber) es mayor que 5 y es menor que 10")
} else
{
print("\(myNumber) es mayor que 10")
}
Does anyone know what the error could be?
I am trying to save the vowels in the variable "vowel" separating them by commas, but python takes it as a complete text.
letra = input(str("Introduzca una letra: "))
vocal = "a","e","i","o","u"
def abc(letra,vocal):
if letra == vocal:
print("True")
else:
print("False")
abc(letra,vocal)
How can I get the variable to take the letters separately?
#Definir una función que calcule la longitud de una lista
# o una cadena
def longi(numero,lista):
lista = [1,2,3,4,5,36,7,8,9,3,4,5,6,7,5,4,3,4]
numero = 0
for i in lista:
numero = numero + 1
print(numero)
longi(numero,lista)
I am trying to define a function which counts how many numbers have a list, but when calling the function with the arguments it tells me that they are not defined. Does anyone know why?
This is the code:
procedure TForm1.ButtonDotClick(Sender: TObject);
begin
if (POS('.', txtResult.Text))<>0 then
exit
else
txtResult.Text := txtResult.Text + ButtonDot.Caption;
end;
The error that appears is the following: E2003 Undeclared identifier: 'Caption'
Can anybody help me?
procedure TForm1.ButtonPlusLessClick(Sender: TObject);
var
pMinus: Real;
begin
pMinus := StrToFloat(txtResult.Text);
txtResult := FloatToStr(-1 * pMinus);
end;
The error that appears is the following: E2010 Incompatible types: 'TEdit' and 'string'.
tput: No value for $TERM and no -T specified
I am making a code in bash and it does not execute correctly. I think it may be a bug found in the bashrc file .
#!/bin/bash
#Variables Globales
function Unconfirmedtransactions()
{
echo '' > ut.tmp
while [ "$(cat ut.tmp | wc -l)" == "1" ]; do
curl -s "$unconfirmed_transactions" | html2text > ut.tmp
done
hashes=$(cat ut.tmp | grep "Hash" -A 1 | grep -v -E "Hash|\- -|Time")
echo $hashes
tput cnorm
}
parameter_counter=0; while getopts "e:h:" arg; do
case $arg in
e) exploration_mode=$OPTARG;let parameter_counter+=1;;
h) helpPanel;;
esac
done
tput civis
Apparently the variable $TERM
has no value assigned.
I am trying to create the Figure class with its respective functions but it tells me that Figure is not defined. What is the mistake?
class Figura:
def __init__(self):
self._lados = None
def main():
triangulo = Figura()
cuadrado = Figura()
cuadrado._lados = 4
triangulo._lados = 3
print(f"El triángulo tiene {triangulo._lados} lados.")
print(f"El cuadrado tiene {cuadrado._lados} lados.")
if __name__ == '__main__':
main()
ERROR => NameError: name 'Figure' is not defined