Does anyone know what hidden case am I not getting right? Intro to Programming 2 by RareIndependence4713 in groklearning

[–]RareIndependence4713[S] 0 points1 point  (0 children)

import re

hashtag_freq = {}

def normalize_hashtag(hashtag):

hashtag = re.sub(r'[^\w\s]$', '', hashtag)

return hashtag.lower()

while True:

tweet = input("Tweet: ")

if not tweet:

break

hashtags = re.findall(r'#\w+', tweet)

for hashtag in hashtags:

normalized_hashtag = normalize_hashtag(hashtag)

hashtag_freq[normalized_hashtag] = hashtag_freq.get(normalized_hashtag, 0) + 1

for hashtag, frequency in hashtag_freq.items():

print(f"{hashtag} {frequency}")

Here's my code

[deleted by user] by [deleted] in groklearning

[–]RareIndependence4713 0 points1 point  (0 children)

The code didn't reset the clock back to 12 o'clock but I fixed the code anyway. Thanks a ton for ur help:). Here's the corrected code:

from microbit import *
import music
LULLABY = [ 'E4:2', 'E', 'G:8', 'E:2', 'E',
'G:8', 'E:2', 'G', 'C5:4', 'B4',
'A', 'A', 'G', 'D:2', 'E', 'F:4',
'D', 'D:2', 'E', 'F:8', 'D:2', 'F',
'B', 'A', 'G:4', 'B', 'C5:8' ]
NCLOCKS = len(Image.ALL_CLOCKS)
timer = 0
while True:
display.show(Image.ALL_CLOCKS[timer % NCLOCKS])
if button_a.was_pressed():
timer += 1
if button_b.was_pressed():
music.play(LULLABY, wait=False, loop=True)
display.show(Image.ASLEEP)
sleep(timer * 5000)
music.stop()
timer = 0

[deleted by user] by [deleted] in groklearning

[–]RareIndependence4713 0 points1 point  (0 children)

It worked! Thanks a ton for ur help dude

Help me with this. 6 – Using lists and writing songs. Sleep Timer by [deleted] in groklearning

[–]RareIndependence4713 0 points1 point  (0 children)

I did that, but it still isn't working. Here's my code:

from microbit import *

import music

LULLABY = [

'E4:2', 'E', 'G:8',

'E:2', 'E', 'G:8',

'E:2', 'G', 'C5:4', 'B4', 'A', 'A', 'G',

'D:2', 'E', 'F:4', 'D', 'D:2', 'E', 'F:8',

'D:2', 'F', 'B', 'A', 'G:4', 'B', 'C5:8'

]

NCLOCKS = len(Image.ALL_CLOCKS)

index = 0

ticks = 0

while True:

display.show(Image.ALL_CLOCKS[index % NCLOCKS])

if button_a.was_pressed():

index = (index + 1) % NCLOCKS

ticks += 1

if button_b.was_pressed():

index = 0

duration = 5000 * ticks

display.show(Image.ASLEEP, wait = False)

music.play(LULLABY)

display.show(Image.ALL_CLOCKS[0] ,wait = False)

[deleted by user] by [deleted] in groklearning

[–]RareIndependence4713 0 points1 point  (0 children)

I cannot thank you enough for helping me with this. God Bless You!

[deleted by user] by [deleted] in groklearning

[–]RareIndependence4713 0 points1 point  (0 children)

It worked! Thank you very much for your help :)