Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
29th July To 4th August 2019
#1
The purpose of this thread is to compile a list of posts made between Mon 29th July To Sun 4th August that are well established posts to be nominated to be the top pick of the week.
A Well established post means it is detailed, instructional, and that it goes above and beyond the normal answer, etc.

Please make 1 post linking to the post you are nominating (by copying the post ID # in the top right area of the post).
You may make an additional comment regarding the post you are nominating.
If you have more than post to nominate, make a separate post for each.

Use the like button to cast your votes. you may choose as many as you want. The winner will be the one with the most likes at the end of the week.
Reply
#2
https://python-forum.io/Thread-Trying-to...9#pid87419
Reply
#3
https://python-forum.io/Thread-Occurrenc...7#pid87427
Reply
#4
https://python-forum.io/Thread-Binding-n...1#pid88041
Reply
#5
Today is the last chance for someone other than me to nominate a post for this week.
Also get your votes in by liking a nomination
Reply
#6
Congratulation fishhook Dance your post is this weeks winner.

(Jul-29-2019, 01:21 PM)fishhook Wrote: 1. Don't use range(len(a)), python cycle iterates over values, not indexes, just write
for item in a:
2. Your code works well
a = [100, 100, 50, 20, 100, 30]
x = 100
c = 0
for i in range(len(a)):
    if x == a[i]:
        c = c + 1

print(c)
>>> 3
3. Better code
a = [100, 100, 50, 20, 100, 30]
x = 100
c = sum(1 for i in a if i == x)

print(c)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  5th August To 11th August 2019 Yoriz 2 3,159 Aug-21-2019, 04:34 PM
Last Post: nilamo
  22nd July To 28th July 2019 Yoriz 2 2,814 Jul-29-2019, 04:35 PM
Last Post: Yoriz
  15th to 21st July 2019 Yoriz 2 2,861 Jul-22-2019, 04:56 PM
Last Post: Yoriz
  8th to 14th July 2019 Yoriz 3 3,167 Jul-17-2019, 05:15 PM
Last Post: Yoriz
  Week of 7/5/2019 metulburr 8 4,671 Jul-05-2019, 09:58 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

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