convert python code to java using jython

Solutions on MaxInterview for convert python code to java using jython by the best coders in the world

showing results for - "convert python code to java using jython"
Charlotte
23 Feb 2017
1s=input()
2
3n=int(input())
4
5l=list(input().split())
6
7ans = 0
8
9for i in l:
10
11count=s.count(i) ans+= count*ord(i)
12
13print(ans)
Magdalena
09 May 2016
1def import_file(file):
2    with open(file,"r") as f:
3        lines = f.readlines()
4        sline = []
5        for line in lines:
6          xline=line.split(" ")
7          sline.append(xline)
8    return sline        
9        
10def set_file(idf,q,sline):
11    for i in sline:
12        if idf in i:
13            sline[sline.index(i)][1] = q + "\n"
14            return "Change succeeded"
15    sline.append([idf,q])
16    return "New code added"
17
18def list_file(idf,sline):
19    for i in sline:
20        if idf in i:
21            return sline[sline.index(i)][1]
22    return "Not found"       
23
24def export_file(name,sline):
25    with open(name,'w') as f:
26        for lines in sline:
27            f.write(lines[0] + ' ' + lines[1])
28                                     
29loop = 1
30while loop == 1:
31    choice=int(input("1:Import file\n 2:Set \n 3:List \n 4:Export file \n 5:Quit \n :"))
32    if choice == 1:
33        print("Importing file...")
34        use=import_file(input("Insert the path of the file:"))
35    elif choice == 2:
36        print("Setting file...")
37        print(set_file(input("Insert id:"),input("Insert quantity:"),use))
38    elif choice == 3:
39        print("Listing file...")
40        print(list_file(input("Insert id:"),use))
41        print(use)
42    elif choice == 4:
43        print("Exporting file...")
44        print(export_file(input("Name of the exported file:"),use))
45    elif choice == 5:
46        print("Goodbye")
47        loop = 0
48    
similar questions
queries leading to this page
convert python code to java using jython