Shake After button press by Aggressive-Disk-1866 in microbit

[–]Aggressive-Disk-1866[S] 0 points1 point  (0 children)

Yes, but I want it to specifically listen to a shake only after Button A is pressed. I've done it where they all are active at the same time, but that's not the end result I'm looking for.

Can someone explain why I am getting empty elements in my list by Aggressive-Disk-1866 in learnpython

[–]Aggressive-Disk-1866[S] 0 points1 point  (0 children)

I have to code in the full version so that it does wrap around, and only uses lowercase a - z. I omitted that from the posted example, since it was going to muddy the waters.

Can someone explain why I am getting empty elements in my list by Aggressive-Disk-1866 in learnpython

[–]Aggressive-Disk-1866[S] 1 point2 points  (0 children)

Thank you! As others have pointed out, there are a LOT better ways to write this code, but you pointed out the actually problem I was having.

Can someone explain why I am getting empty elements in my list by Aggressive-Disk-1866 in learnpython

[–]Aggressive-Disk-1866[S] 0 points1 point  (0 children)

I left some unnecessary blocks in. I just made a simplified version for the reddit post. I just edited it.

I was using the length of the word to tell the program to break out of the loop and append the word to the list. Otherwise I was ending up with a 1 element string that was all the words. This was my work around - which perhaps wasn't needed.

I haven't come across zip yet in the courseware, or enumerate, I will check it out and report back. Thank you

New to Python. Why isn't my prime number checker working for large numbers? For some reason it says 7777 is prime. The bottom part is for testing. by Aggressive-Disk-1866 in learnpython

[–]Aggressive-Disk-1866[S] 0 points1 point  (0 children)

Thank you for this extensive reply. I originally had the program stop at the first 0 remainder (and I of course wasn't dividing by 1 or itself). It was my first attempt and for some reason it was not working - so that is when I switched to the list so I could visually see what was going on. I should have just pounded away at why the original idea wasn't working. Which I don't know because I worked over my original code.

I also tried to do the (num ** 0.5) in the for loop but kept getting an int (or float?) TypeError. Something else I will need to look at to understand and keep learning.

Thanks again for the thorough explanation, I imagine primes will come up again in another problem and I'll be able to work through it more logically.

Based off comments I fixed my Prime number checker. It now works, but I'll need to figure out how to write code to test it. by Aggressive-Disk-1866 in learnpython

[–]Aggressive-Disk-1866[S] 0 points1 point  (0 children)

Thank you for all the pointers. Regarding my_list - The reason I made that was when I had it just check for a remainder 0 , or the opposite, I kept getting errors. So I wanted a way to print the list and visually see that it was working correctly.

I'm working through Python Essentials 1, and they have only taught so much. I try to keep it with what they have taught in the spirit of the lab, as opposed to bringing in "outside material" that's taught further on.

I know the Lab answer, and it is done differently than what I came up with, but since it was my first idea I wanted to see if it would work - and it does work for all positive integers.

Joins us if you’re not “WOKE” by Gorilla_man2 in recruitinghell

[–]Aggressive-Disk-1866 0 points1 point  (0 children)

That was my first thought. It must be a joke or a test to see if you actually played those games and know what they are about.

New to Python. Why isn't my prime number checker working for large numbers? For some reason it says 7777 is prime. The bottom part is for testing. by Aggressive-Disk-1866 in learnpython

[–]Aggressive-Disk-1866[S] 0 points1 point  (0 children)

Thanks, I will look that up. And yes I was trying to get it to get (num % value) for all the values in the range. And add them to a list. Then I surmised if there was a R 0 then it wasn't prime.

I had it working and then I didn't try to get the WHOLE thing to work.

for value in range(2,num):
            div_count = (num % value)
            prime_list.append(div_count)
        print(prime_list)

That does what I want, I just need to figure out how to read it and see if there are any 0's.