printing - How to count similar domains in emails and print every domain only once[python]? -


I have 10 hotmail emails, 4 Gmail, 3 mails. I want to analyze the list of emails and print out how many domains (Hotmail, Gmail, etc.) and impressions. But I do it in a very bruteforce way. I know that Python has an elegant short code (like Iteratollos, Islice, Xrange)

Hotmail: 10 Gmail: 4 mail.com: 3

But I get this:

Hotmail 10 Hotmail 10 ... Hotmail 10 Gmail 4 Gmail 4 Gmail 4 Gmail 4 AD

  DRT count_domains (email): For e-mail in email: current_email = Email.split ("@", 2) [1] # partition @, john@mail.com = & gt; Current_emain_counter = 0 for email 2 in Mail.com, # 2 index (current_email) in the list. If current_email == email2.split ("@", 2) [1]: current_domain_counter = current_domain_counter + 1 # print (current_email_ current_domain_counter) )) If you put all the stars in a list, myList says, "You can make it unique by using  
  uniqueList = list (set of myList)  

After this, you can count the events used, e.g.

  countFirst = myList.count (unique list [0])  

You can put things together, such as

set in the domain For
  [[domain, myList.count (domain)]  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -