I'm having a hard time because in JavaScript it was possible to do this:
const x = []
x[0] = 1
x[1] = 2
But in Python when I create an empty list and try to make a statement it says the index is out of range. I can work around the append...
I learned to import modules, but I do not know how to, for example, create a class in a separate file and include it in the main program, how to do that?
Let s be a string with all lowercase characters.
Write a program that prints the largest substring of s in which letters occur in alphabetical order. For example:
s = 'azcbobobegghakl'
The program should print: beggh
If there a...
I'm asking a question that asks to raise the number to 9 and say the last digit I got, but the resolution seems to have passed the time because it had a number of 10 ^ 9, how to solve it in a faster way
My code
import math
while True:
try:...
According to the Python 2.x documentation, it is recommended to use the raw_input function instead of input . Conversely, in the Python 3.x documentation, the raw_input function does not even appear. So does the input...
I'm trying to find the smallest and highest single value of a python array, but something is still flawed.
def pegaExtremosUnicos(v):
i = 1
for i in range(len(v)):
atual = v[i]
j = i - 1;
while (j >=0) and (a...
How can I create a list from the sum of two previous ones without some value appearing repeated, without using the set function?
Example:
>>>a = [1, 2, 3]
>>>b = [3, 4, 5]
>>>c = a + b
>>>print c
[...
The command
python foo.py
When called on the terminal, it runs the sent python file. Imagine that I have a python file that always needs to be called as follows:
xvfb-run python foo.py
to work.
Is there any way I can write something...