gulshan212 Posted April 17, 2023 Share Posted April 17, 2023 Hello this is Gulshan Negi Well, I am writing a program for finding sum of natural numbers but it shows some error at the time of execution. Source Code: n = int(input("Enter the number:" )) sum=0 if n > 1: for i in range(1,n+1): sum+=i: print("The sum of all natural number upto",n,"is ",sum) else: print("Please Enter a value greater than 1") I also checked and took teference from here, but i don't know what I am missing here. Can anyone give their suggestions on this. Thanks Link to comment Share on other sites More sharing options...
Sherzod Posted April 17, 2023 Share Posted April 17, 2023 Hello, Is it related to uniGUI at all? Link to comment Share on other sites More sharing options...
Ron Posted April 18, 2023 Share Posted April 18, 2023 Quote Can anyone give their suggestions on this. We are happy users of Delphi, so unfortunately we don't care very much about Python not working. Python - even the name of the game tells one to stay away. Who knows, if it bites? Link to comment Share on other sites More sharing options...
gulshan212 Posted April 18, 2023 Author Share Posted April 18, 2023 Sorry for inconvince but I think it is a good platform and I suppose that here any expert can reply its answer therefore I ask my query. Thanks Link to comment Share on other sites More sharing options...
Sherzod Posted April 18, 2023 Share Posted April 18, 2023 4 minutes ago, gulshan212 said: Sorry for inconvince but I think it is a good platform and I suppose that here any expert can reply its answer therefore I ask my query. Perhaps you are on the wrong forum. Link to comment Share on other sites More sharing options...
gulshan212 Posted April 18, 2023 Author Share Posted April 18, 2023 Ok, will keep these point in mind for future reference. Thanks a lot for your kind response. Link to comment Share on other sites More sharing options...
Ron Posted April 19, 2023 Share Posted April 19, 2023 When I put your code into https://pynative.com/online-python-code-editor-to-execute-python-code/ it works fine. Only had to replace the : with a ; at the end of this line: sum+=i; Result: Enter the number:The sum up to 3 is 6 1 Link to comment Share on other sites More sharing options...
Recommended Posts