What's new

Help Pano mag bura ng double quotes sa python sets?

Status
Not open for further replies.

Chunchunmaru

Eternal Poster
Joined
Aug 31, 2021
Posts
766
Reaction
288
Points
393
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
 
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'
 
Last edited:
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?
IMG_20211214_021728.jpg

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
 

Attachments

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'
IMG_20211214_022046.jpg

Ganto ko po inadd yung data(base sa handout)
 

Attachments

Python:
# 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)

so alisin mo yung square brackets sa birth_month
 
Last edited:
Python:
# 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
HAHAHAHA SALAMAT IDOL UMAI, ginawa ko palang set yung kumukuha nung value HAHAHAHAHA
 
Ganito 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'}

HAHAHAHA SALAMAT IDOL UMAI, ginawa ko palang set yung kumukuha nung value HAHAHAHAHA
So solved na?
 
Ganito 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
 
Ano pong pinagkaiba ng debug sa run?

Yung debugging, mamomonitor/makikita mo kung anong result ng bawat line.
for example:
Yung step into meaning move to next line of code
Yun red ayan yung breakpoint kung saang line mo gusto magstart yung debugging..

1639428436656.png



Yung nasa gilid, ayan yung result. Diyan palang makikita mo na kung anong result.

1639428723239.png
 

Attachments

Last edited:
Status
Not open for further replies.
Back
Top