What do you want to save?
Add Code snippet
New code examples
-
Python 2022-03-17 02:55:04
Write a python program to find the longest words.
def longestword(filename): with open(filename,'r+') as f: words = f.read().split() max_len_word = max(words,key=len) max_len = len(max(words,key=len)) print('maximum lenth word in file :',max_len_word) print('lenth is : ',max_len) longestwor... Add solution -
Python 2022-03-05 19:00:29
Python Program to Count the Occurrences of a Word in a Text File
#get file object reference to the file file = open("C:\workspace\python\data.txt", "r") #read content of file to string data = file.read() #get number of occurrences of the substring in the string occurrences = data.count("python&... Add solution -
Python 2022-03-03 05:15:16
random choice without random module
# First let's make a function that makes a random number def randint(a, b): "Return random integer in range [a, b], including both end points." return a + randbelow(b - a + 1) def randbelow(n): "Return a random int in the ran... Add solution -
Javascript 2022-03-02 20:40:53
c# json from file to object
// read file into a string and deserialize JSON to a type Movie movie1 = JsonConvert.DeserializeObject<Movie>(File.ReadAllText(@"c:\movie.json")); // deserialize JSON directly from a file using (StreamReader file = File.OpenText(@"c:... Add solution -
Python 2022-02-18 14:40:06
_pickle.UnpicklingError: the STRING opcode argument must be quoted python
original = "word_data.pkl" destination = "word_data_win10.pkl" content = '' outsize = 0 with open(original, 'rb') as infile: content = infile.read() with open(destination, 'wb') as output: for line in content.splitli... Add solution
Best helpers
Ranking is empty