Chunchunmaru
Eternal Poster
Umay, puro split at replace method ung asa google pero ayaw naman! Pano po mag bura ng double quotes sa value ng sets kapag python? Okay naman kapag isa lang nilalagay ko pero kapag madami nag kakaroon ng double quotes
sets = set()
sets.add('"double_quote"')
sets.add('"another_double_quote"')
sets.add('"another___double_quote"')
clean = set({x.replace('"', "'") for x in sets})
for c in clean:
print(c)
output
'another_double_quote'
'double_quote'
'another___double_quote'
Di ko nagets masyado. Show an example =D
replace should work
If PC gamit mo and vs code, baka may formatter extension ka like "black" na naka auto format kapag nag save?
Di ko nagets masyado. Show an example =D
replace should work
If PC gamit mo and vs code, baka may formatter extension ka like "black" na naka auto format kapag nag save?
Ganito ba ibig mong sabihin?
Python:sets = set() sets.add('"double_quote"') sets.add('"another_double_quote"') sets.add('"another___double_quote"') clean = set({x.replace('"', "'") for x in sets}) for c in clean: print(c) output 'another_double_quote' 'double_quote' 'another___double_quote'
View attachment 1757740
Ganto po o, yung ininput ko sa taas plain letters lang, tapos kapag i di display my extra symbol na nakalagay, pano po alisin?
Natatanggal ko ung double bracket kapag ginamitan ko ng split pero ung double quote ayaw
Nag e error po pag inalis yonTry mo alisin yung square brackets sa
set([str(self.birth_month1) ......]
Salamat po hahaha sa laptop kase ako nag co code nakaka hassle i re type sa pc, kanina pa kase ako e pagod na din kakaisip umai HAHAHAwait code ko lang manual ss mo haha para maexplain ko mabuti
# BEFORE
birth_month1 = ([input(str(f'Birth Month: '))])
group1 = set([str(birth_month1)])
# OUTPUT: {"['1']"}
print(group1)
# AFTER
birth_month1 = input('Birth Month: ')
group1 = set([str(birth_month1)])
# OUTPUT: {'1'}
print(group1)
HAHAHAHA SALAMAT IDOL UMAI, ginawa ko palang set yung kumukuha nung value HAHAHAHAHAPython:# BEFORE birth_month1 = ([input(str(f'Birth Month: '))]) group1 = set([str(birth_month1)]) # OUTPUT: {"['1']"} print(group1) # AFTER birth_month1 = (input(str(f'Birth Month: '))) group1 = set([str(birth_month1)]) # OUTPUT: {'1'} print(group1)
so alisin mo yung square brackets sa birth_month
birth_month1 = input('Birth Month 1: ')
birth_month2 = input('Birth Month 2: ')
birth_month3 = input('Birth Month 3: ')
group1 = set([str(birth_month1), str(birth_month2), str(birth_month3)])
print(group1)
Birth Month 1: a
Birth Month 2: b
Birth Month 3: c
# OUTPUT: {'a', 'b', 'c'}
So solved na?HAHAHAHA SALAMAT IDOL UMAI, ginawa ko palang set yung kumukuha nung value HAHAHAHAHA
Opo HAHAHA tama yung sinabi mo salamat poGanito ba desired output mo?
Python:birth_month1 = input('Birth Month 1: ') birth_month2 = input('Birth Month 2: ') birth_month3 = input('Birth Month 3: ') group1 = set([str(birth_month1), str(birth_month2), str(birth_month3)]) print(group1) Birth Month 1: a Birth Month 2: b Birth Month 3: c # OUTPUT: {'a', 'b', 'c'}
So solved na?
Opo HAHAHA tama yung sinabi mo salamat po
Thanks po talaga, natapos ko din, yun lang pala mali ko heheheheWelcome.
Try mo next time idebug para makita mo each outputThanks po talaga, natapos ko din, yun lang pala mali ko hehehehe
Ano pong pinagkaiba ng debug sa run?Try mo next time idebug para makita mo each output
Ano pong pinagkaiba ng debug sa run?