Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Code optimization
Post: RE: Code optimization

It is funny but it works the same, Thank you anyway!:)
Vidar567 General Coding Help 2 1,544 Nov-24-2020, 10:27 PM
    Thread: Code optimization
Post: Code optimization

Hello guys, Have you got any sugesstions how to optimize my code? I would like to use maybe other solution to compile faster. Thank you for any sugesstions def countit(numericals=[1, 1, 2, 2, 3, 3], ...
Vidar567 General Coding Help 2 1,544 Nov-24-2020, 09:03 PM
    Thread: None in the list error
Post: RE: My excersise is

I made it: def makelist(main = [3, 4, 3, 2, 6, 1, 2, None]): result = [] for x in main: if x != None: result.append(x) else: pass return list(dict.f...
Vidar567 General Coding Help 2 1,768 Nov-24-2020, 08:44 PM
    Thread: None in the list error
Post: None in the list error

My excersise is to output list without occurring in the list. I made it, but there is another condition which I do not really understand and it gives me an error. Condition: 0 <= LinkedListNode[i]...
Vidar567 General Coding Help 2 1,768 Nov-24-2020, 08:30 PM
    Thread: Output with none, print(x) in function
Post: RE: Output with none, print(x) in function

I find out to pack it into list and then unpack using loop, but to be honest I do not like it, do you have any sugesstions? def oddNumbers(l=1, r=7): # Write your code here lista = [] for ...
Vidar567 General Coding Help 3 2,522 Nov-24-2020, 02:08 PM
    Thread: Output with none, print(x) in function
Post: Output with none, print(x) in function

Do you have any suggestions how to change this None in an output value? I have read that it is because of print(x), but... if I delete or change print(x) to return x, for loop will end at 1 number. I...
Vidar567 General Coding Help 3 2,522 Nov-24-2020, 01:51 PM
    Thread: Perfect numbers
Post: RE: Perfect numbers

That's true I find it just seconds before: "The if (sum == n) check needs to be done outside the loop. Otherwise you might pick up numbers such that the sum of a subset of divisors equals the number....
Vidar567 General Coding Help 2 1,920 Nov-23-2020, 10:29 PM
    Thread: Perfect numbers
Post: Perfect numbers

Gentlemans, do you have any suggestions why this code doesn't output proper values? When I write end = 100 it outputs: [6, 24, 28] 24 is not a perfect number. def perfect_number(end = 100): li...
Vidar567 General Coding Help 2 1,920 Nov-23-2020, 09:50 PM
    Thread: Yield generator weird output
Post: RE: Yield generator weird output

def primes(to_number=100): lista = [2] for x in range(2, to_number): if x % 2 == 0: pass else: lista.append(x) return lista result = primes() print(...
Vidar567 General Coding Help 8 3,295 Nov-23-2020, 09:49 PM
    Thread: Yield generator weird output
Post: RE: Yield generator weird output

def primes(to_number = 5): new_list = [] for x in range(to_number + 1): for y in range(to_number + 1): new_list.append(y) return new_list isprime = bool(Fals...
Vidar567 General Coding Help 8 3,295 Nov-23-2020, 07:17 PM
    Thread: Yield generator weird output
Post: Yield generator weird output

Hello, I would like to create function primes(), but when I return values from the first loop function stops. Instead of return I try using yield, but it seems that I should make some additional code...
Vidar567 General Coding Help 8 3,295 Nov-23-2020, 03:01 PM
    Thread: If, elif, else doesn't work well
Post: If, elif, else doesn't work well

print("Draw it?") chart = str(input()) if chart == "Tak" or "tak" or "t": print("Draw chart) elif chart == "Nie" or "nie" or "n": print("You chose to ...") else: print("inappropriate ch...
Vidar567 General Coding Help 5 2,888 Nov-21-2020, 01:20 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020