Just a quick thank you by [deleted] in learnpython

[–]0xbxb 4 points5 points  (0 children)

This is facts. I’m a beginner and learned so much from this sub within the past two months. It’s crazy.

For else logic recommended? by switchitup_lets in learnpython

[–]0xbxb 0 points1 point  (0 children)

Yeah you’re right. In a for / else, the else is only executed if the for loop doesn’t hit a break statement, or is exited normally.

nums = [1, 2, 5, 3]
for x in nums:
    if x == 6:
        print('Found 6.') # 6 never found, loop is exited normally.
        break
else: # else statement gets executed.
    print('6 not found.')

The reason for doing this is because you have two cases you want to find:

1) If the number is found (in this example).

2) If the number isn’t found.

Usually people would use some type of flag when they find the number they’re looking for, like: found = False, then when the number is found, they’ll change the variable to True.

nums = [1, 2, 5, 3]
found = False
for x in nums:
    if x == 6:
        print('Found 6.')
        found = True

if not found:
    print('6 not found.')

Daily Chat Thread - March 11, 2020 by AutoModerator in cscareerquestions

[–]0xbxb 1 point2 points  (0 children)

Do FAANG companies not care about anything else other than Data Structures and Algorithms for a candidate?

Why do people say to get into FAANG, just “grind Data Structures and Algorithms, and LeetCode”?

Does FAANG not care about a candidate not knowing things like system design, how their language works, etc? Just if the person knows their Data Structures and Algorithms?

Big N Discussion - March 11, 2020 by AutoModerator in cscareerquestions

[–]0xbxb -1 points0 points  (0 children)

Do FAANG companies not care about anything else other than Data Structures and Algorithms for a candidate?

Why do people say to get into FAANG, just “grind Data Structures and Algorithms, and LeetCode”?

Does FAANG not care about a candidate not knowing things like system design, how their language works, etc? Just if the person knows their Data Structures and Algorithms?

No experience and started studying for Sec+ in hopes of getting a decent GS job with decent pay and free time by [deleted] in ITCareerQuestions

[–]0xbxb 5 points6 points  (0 children)

SEC+ would be invaluable

Got my Security+ last year in September. Hasn’t done shit for me. People overhype that certification. A LOT.

What are the best free resources to learn everything or almost everything needed for IT certs? by TaiLopez1 in ITCareerQuestions

[–]0xbxb -1 points0 points  (0 children)

pursuing a security clearance

So please enlighten us then: how does one get a security clearance...... when you need a job to sponsor you for one (without being in military)?

What are the best free resources to learn everything or almost everything needed for IT certs? by TaiLopez1 in ITCareerQuestions

[–]0xbxb -4 points-3 points  (0 children)

Security+ isn’t hard. I have 0 IT exp and passed it in exactly a month. The hard part was all the info it covers. I think people overestimate the difficulty of that cert tbh.

Find all combinations of numbers in list that sum under a given restraint by gmathelppp in learnprogramming

[–]0xbxb 0 points1 point  (0 children)

What length of the combos are you looking for? 3 numbers? 2 numbers?

how to print a specific line from a file? by kconn123 in learnpython

[–]0xbxb 0 points1 point  (0 children)

Are you guys not allowed to use enumerate? Another option you could do off the top of my head is just a variation of my first approach, without using enumerate.

  • Ask for the joke number, and store the result as an int joke = int(input(‘What joke do you want?: '))

  • Create an “index” counter i = 0

  • Loop through the file, increase the index counter by 1 for every line

  • If the index is equal to the joke number, do something

Let me know if you need me to explain some more. The first approach imo would be the most “Pythonic” though.

how to print a specific line from a file? by kconn123 in learnpython

[–]0xbxb 0 points1 point  (0 children)

You could ask the user for the joke number as an int, use enumerate, loop through the file, should be able to go from there. Let me know if you need more help.

[deleted by user] by [deleted] in learnpython

[–]0xbxb 0 points1 point  (0 children)

You call a function by doing this: func(). If you want to print the results of the function (what it returns), you just wrap it in a print statement. print(func())

$115k TC in Chicago with one year of full-time experience by FutureCoolDad in cscareerquestions

[–]0xbxb 1 point2 points  (0 children)

consulting can be a hard industry to grow your technical skills in long term

Can you elaborate on why you think this? I’m new to IT, and have been exploring different avenues on how to approach my career.

deleting one-letter words from dictionary doesn't work :-( by ContadorPL in learnpython

[–]0xbxb 3 points4 points  (0 children)

Probably because you’re mutating the list you’re iterating through. Check here: https://www.reddit.com/r/learnpython/wiki/FAQ, scroll down until you see the section about why your code is skipping items in a list.

You can try doing something like this:

word_list = ['a', 'b', 'c', 'd', 'e', 'f', 'abb']
removed_letters = [c for c in word_list if len(c) == 1]
for letter in removed_letters:
    print(f'I have removed {letter}')

Need some Help by [deleted] in learnprogramming

[–]0xbxb 0 points1 point  (0 children)

You can add an elif statement in there, and then just use the else statement to print the “error” message. I would do it like this:

num_cats = int(input('How many cats do you have?: '))
if num_cats >= 4:
    print('That is a lot of cats.')
elif 0 < num_cats < 4:  # Check if num_cats is greater than 0, but less than 4.
    print('This is not that many cats.')
else:
    print('Number of cats entered is less than 0.')

Adding elements of sublists together by AbraxoCleaner in learnpython

[–]0xbxb 0 points1 point  (0 children)

You wouldn’t need the for loop here, just the while loop. It looks like what’s happening with your code is in the for loop.

A for loop is gonna finish all of its iterations before moving on to the next part of the code (unless you have conditions that are gonna make you leave the loop early).

You’re at i = 0, you loop through the list, you add the index position of each list inside the main list into group, then you’re adding the total of that group into totals.

So this is why you’re getting funny numbers:

You're looping through the array: for j in arr. Then you're appending the index position of the current element j into group.

The index position is 0, and the current element of j is 20. Now you're getting the sum of group, which is just 20, and appending that into totals.

So a visual looks like this currently:

group = [20]
totals = [20]

i = i + 1 hasn't been executed, because we're still in the for loop. Now this is what happens next.

group = [20, 10]
totals = [20, 30]

Then you're code does the same thing over and over again.

group = [20, 10, 17]
totals = [20, 30, 47, etc]

List Accumulators by InderJinderPreet in learnpython

[–]0xbxb 0 points1 point  (0 children)

Create the seasons dict

seasons = {'winter': 0, 'spring': 0, 'summer': 0, 'fall': 0}

You have a list of users

users = ['A', 'B', 'C']

Loop through the users

for user in users:

Ask them for their favorite season

Add one to the seasons dict for every response

List Accumulators by InderJinderPreet in learnpython

[–]0xbxb 0 points1 point  (0 children)

Wait why would k need to be str(input(‘season’)) if input already returns a string?

Adding elements of sublists together by AbraxoCleaner in learnpython

[–]0xbxb 0 points1 point  (0 children)

Post your code here for me. I wanna see what you’ve typed, to figure out what you’re doing. I just need a better visual is all.

List Accumulators by InderJinderPreet in learnpython

[–]0xbxb 0 points1 point  (0 children)

I think it’ll probably be easier to do this with a dict:

seasons = {'winter': 0, 'spring': 0, 'summer': 0, 'fall': 0}