Facebook
From Sloppy Pheasant, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 342
  1. def listToString(s):
  2.     # initialize an empty string
  3.     str1 = " "
  4.  
  5.     # return string
  6.     return (str1.join(s))
  7.  
  8.  
  9. dict = {68: 'dnmjhmj', 45: 'ccccnnghjjjjjjjyey', 3: 'hjlrrrrrrrrrrrrrrwt', 21: 'a', 24: 'cbnmnbn', 97: 'mjmjujjedtjtyyt', 63: 'baaaaaaaaaaaa', 9: 'abbbssskkklllw', 59: 'djkjkjfjkfmk', 48: 'dhgjkuyfuuj', 12: 'shfnhnhn', 42: 'dyjukryejumdeyu', 69: 'abbcg', 39: 'eeettyurjiri', 23: 'shfdnjhmmk', 51: 'gtweerijklv', 55: 'dstejussnvxm', 33: 'aasssssgggw', 66: 'htttttwrtkkkkg', 75: 'jklddddddew', 78: 'fgsggggggg', 88: 'vnxcnbxdhjg', 76: 'xzsgbxsfghnyj', 64: 'ahahattttaaaaa', 15: 'yiiiuuuucc', 22: 'dhjuyyyyyyyyyyyyo', 27: 'oprtttyyowwwwddddddddk', 35: 'sghgfhsgkj', 18: 'dlggh', 57: 'wwddddgtttqqqlllo', 36: 'aaaaaaabbbbbbb', 81: 'aaaaaaab', 56: 'yhsyhjuiuopopppp', 30: 'abcgggjjkkkwwwllwwwwwwf', 19: 'vzvzvzbvxxxx', 44: 'zvbnbhnhshnghndmhgjmjh', 17: 'hdjkkkkkreaaa', 61: 'mmmmmswyhjsw', 28: 'djhfmhjm', 65: 'ejjjjjjjjjjm', 29: 'dhmnjmk', 37: 'ttttttttttwywjummmmmm', 94: 'qryuwyuutiutjdgggggggggmn', 31: 'ccccmmmfffffkr', 52: 'hshhyhtyhtyh', 6: 'nxzcsrtwryu', 34: 'asrhsytjutyjiki', 58: 'fkjjkkfjjfghj'}
  10.  
  11. print(" Nowy słownik to : \n ", dict)
  12.  
  13. tab = []
  14. tab = dict.items()
  15.  
  16. tab2 = [*dict.values()]
  17. print(" Lista z wartościami słownika ",tab2)
  18.  
  19. for i in tab2:
  20.     a = listToString(i)
  21.  
  22.     count = 0
  23.     maxcount = 0
  24.     lastCharacter = ""
  25.     longestcharacter = ""
  26.  
  27.     for ch in a:
  28.         if (ch == lastCharacter):
  29.             count += 1
  30.             if (count > maxcount):
  31.                 maxcount = count
  32.                 longestcharacter = ch
  33.  
  34.         else:
  35.             count = 1
  36.             lastCharacter = ch
  37.  
  38.     print(i)
  39.     print(longestcharacter)
  40.     print(maxcount)
  41.  
  42.     print(i, " najdłuższy łańcuch znaków to ", longestcharacter, " jego długość to ", maxcount)
  43.