0

Convert Java program to Python program

Hello I am learning Java programming I know Python programming language very well. Could you please convert the Python program to java program . This the program for sum of digits . n="100" sum_of_digits=0 for i in range(len(n)): sum_of_digits+=int(n[i]) print(sum_of_digits)

24th Aug 2020, 5:33 AM
Varshith
Varshith - avatar
7 odpowiedzi
0
Yes 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 I have tried .
24th Aug 2020, 5:39 AM
Varshith
Varshith - avatar
0
I have tried this in java class sample{ public static void main(String args[]){ String s="123"; int count=0; for(int i=0;i<s.length();i++){ count+=Integer.parseInt(s.charAt(i)); } } }
24th Aug 2020, 5:41 AM
Varshith
Varshith - avatar
0
Thank you 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 but why you have used double quotes at line 7
24th Aug 2020, 6:08 AM
Varshith
Varshith - avatar