The method copy()
makes a shallow copy of the list, but I don't see any point in using it, if I want to make a copy of the list I just do:
lista2 = lista1
Instead of:
lista2 = lista1.copy()
What is the method for copy()
?
The method copy()
makes a shallow copy of the list, but I don't see any point in using it, if I want to make a copy of the list I just do:
lista2 = lista1
Instead of:
lista2 = lista1.copy()
What is the method for copy()
?
#!usr/bin/env python
def vocales(string):
if "A" or "a" or "E" or "e" or "I" or "i" or "O" or "o" or "U" or "u" in string:
nvocalesami = (string.count("a"))
nvocalesama = (string.count("A"))
nvocalesemi = (string.count("e"))
nvocalesema = (string.count("E"))
nvocalesimi = (string.count("i"))
nvocalesima = (string.count("I"))
nvocalesomi = (string.count("o"))
nvocalesoma = (string.count("O"))
nvocalesumi = (string.count("u"))
nvocalesuma = (string.count("U"))
part1 = (nvocalesami + nvocalesama + nvocalesemi + nvocalesema + nvocalesimi + nvocalesima)
part2 = (nvocalesomi + nvocalesoma + nvocalesumi + nvocalesuma)
todo = (part1 + part2)
return ("Hay",todo,"vocales en la frase")
else:
return("No hay vocales en la frase")
I have a problem with this code when using the vowels function with an argument without vowels, for example:
Departure
vocales("r")
Hay 0 vocales en la frase
Why doesn't "There are no vowels in the sentence" come out?
In my program ( Python 3.5
) I want to execute a function at a certain time regardless of what phase of the code it is in. But I don't know of any statement that checks all the time (even in the course of the program) what time it is and if it is, for example, 13:15 to execute that function. A while
would not work because it would always be executing the loop but not executing the program. Any solution?
My OS is Windows 7 Ultimate.
Why can't you declare variables that start with a number in Python?
Example:
prueba1 = "hola mundo" #bien
1prueba = "hola mundo" #mal