+ 3

HELP ME DOING THIS PYTHON PROGRAM

Write a Python program to find the repeated items of a tuple.

28th Oct 2020, 8:55 AM
Rudresh
Rudresh  - avatar
7 Respostas
+ 2
Question section is for your doubts you found in your code not for assignment. Try yourself then ask where you got stucked.
28th Oct 2020, 9:00 AM
Kashyap Kumar
Kashyap Kumar - avatar
+ 2
Rudresh you didn't provide the code... Without that you won't get an answer.
28th Oct 2020, 9:07 AM
Kashyap Kumar
Kashyap Kumar - avatar
+ 2
Thanks Abhay
28th Oct 2020, 9:18 AM
Rudresh
Rudresh  - avatar
+ 1
You can use a dictionary data structure to store how many times a character occur and then print out those characters whose occurence is more than 1 Do it like this , Take a variable count initialized to 0, Iterate over the tuple then check if item in tuple is in dictionary ,if yes increment the count by 1 and assign it as value to it's respective key(item)=>dict[item]=count finally iterate over the dictionary items and check value is greater than 1 if yes print out its respective key Edit:from "if yes" I meant if item is not in dictionary insert the item in dictionary by incrementing count value by 1 ,if item is in dictionary then take the previous count value of it and increment it by one ,let me know if get stuck anywhere
28th Oct 2020, 9:15 AM
Abhay
Abhay - avatar
+ 1
this is the code to get repeating items and non repeating items: https://code.sololearn.com/cd9R3KfnEh9p/?ref=app
28th Oct 2020, 9:33 AM
Shadoff
Shadoff - avatar
0
it's not an assignment I was doing practice and I got stuck myself in this program. I try but I can't do it
28th Oct 2020, 9:05 AM
Rudresh
Rudresh  - avatar
0
here it is mytup=("a","b","a","c") for i in mytup: for j in mytup: if i==j: print(j,"is repeated") else: print("Not repeated")
28th Oct 2020, 9:11 AM
Rudresh
Rudresh  - avatar