Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Simple question
Post: RE: Simple question

But what I'm talking about is that the user types the numbers in 1 line: 3 5 7 2 53 2 and not: 23 5 7 2 53 2 I have it like this now: t.extend(input().split())
1234 General Coding Help 4 2,296 Dec-04-2020, 10:44 AM
    Thread: Simple question
Post: Simple question

Hi, is there a faster way of changing s list full of numbers in a "5" format, into a int(5) format than: for i in range(len(a)): a[i]=int(a[i])
1234 General Coding Help 4 2,296 Dec-04-2020, 10:02 AM
    Thread: Find _ in a list
Post: RE: Find _ in a list

Yeah what I had was a typo, but 1 more thing, if for example there is a list(5,7,2,9,34) and I run the program with target = 7, the result will be 5, because it will only do lower that 7, instead of l...
1234 General Coding Help 15 5,492 Dec-01-2020, 07:20 PM
    Thread: Find _ in a list
Post: RE: Find _ in a list

I've changed the target to 111, the program returned 140. Why if there is a 100, that is smaller, and 140 isn't?
1234 General Coding Help 15 5,492 Dec-01-2020, 06:35 PM
    Thread: Find _ in a list
Post: RE: Find _ in a list

(Dec-01-2020, 05:56 PM)bowlofred Wrote: (Dec-01-2020, 05:45 PM)1234 Wrote: And what if my target is 100 and there is no 100 in the list, so I want to take the closest number to 100 that is smaller...
1234 General Coding Help 15 5,492 Dec-01-2020, 06:33 PM
    Thread: Find _ in a list
Post: RE: Find _ in a list

(Dec-01-2020, 04:51 PM)bowlofred Wrote: import bisect target = 100 sorted_list = [1, 2, 5, 6, 100, 102, 110, 140, 145] pos = bisect.bisect_left(sorted_list, target) # where to insert, so the number...
1234 General Coding Help 15 5,492 Dec-01-2020, 05:45 PM
    Thread: Find _ in a list
Post: RE: Find _ in a list

Thanks, quick question, in binary search how do you make the value that your looking for equal or smaller than 100?
1234 General Coding Help 15 5,492 Dec-01-2020, 03:19 PM
    Thread: Find _ in a list
Post: RE: Find _ in a list

(Nov-30-2020, 04:44 PM)deanhystad Wrote: Is it ok to sort the list first? Yes, my list is very big, and there is thousands of numbers bigger than the ones from list 'a', so even if the list is sorte...
1234 General Coding Help 15 5,492 Nov-30-2020, 07:21 PM
    Thread: Find _ in a list
Post: Find _ in a list

Hi, I was wondering is there a way that you can find the largest number in a list that is equal or smaller than my chosen number, without going through the whole list every time I want to do it? Is th...
1234 General Coding Help 15 5,492 Nov-30-2020, 04:31 PM
    Thread: Digits of a number
Post: Digits of a number

Hello, Does anyone know a way of taking digits of a number, putting into a list, and adding them together quicker than this? while x>0: t.append(x%10) l+=x%10 x=(x-x%10)//10...
1234 General Coding Help 2 1,846 Nov-27-2020, 05:03 PM

User Panel Messages

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