[Solved] Use a formatted string to separate groups of digits

This is one way to achieve what you are looking to do: number = “12345678910” print( ‘number id {0}.{1}.{2}-{3}’.format( *[number[i:i+3] for i in range(0,len(number), 3)] ) ) #number id 123.456.789-10. There are a few problems with your code. First the first number in the “{0…}” refers to the positional argument in the format() function. In … Read more

[Solved] Find distance between 2 lat and lon point. I have used the formula but answer is not what you expect

Well, you forgot to convert to radians : public double distance(double x, double y, double x2, double y2) { // r is earth’s radius (mean radius = 6,371km) double r = 6371e3; double toMile = 0.000621371; double latDiff = (x2 – x)*(Math.PI)/180; double lonDiff = (y2 – y)*(Math.PI)/180;; // a is the square of half … Read more

[Solved] Could not push integer value in Stack. Can not convert char to int [closed]

Apparently type char is converted to ascii code. You have to use string to get the real number. Try this if (Char.IsDigit(c)) intChar.Push( Convert.ToInt32(c.ToString()) ); another way is to use GetNumericValue function. Since it returns double, it needs to be cast to int. if (Char.IsDigit(c)) intChar.Push( (int)Char.GetNumericValue(c) ); solved Could not push integer value in … Read more

[Solved] No match for Java Regular Expression

Your content contains no ” quotes, and no text gm, so why would you expect that regex to match? FYI: Syntaxes like “foo”gm or /foo/gm are something other languages do for regex literals. Java doesn’t do that. The g flag is implied by the fact that you’re using a find() loop, and m is the … Read more

[Solved] How would I convert a str to an int?

First, use split() to split the input into a list. Then, you need to test isnumeric() on every element of the list, not the whole string. Call int() to convert the list elements to integers. Finally, add the sum to counter, not counter_item. my_list = input(“Input your list.(Numbers)\n”).split() while not all(item.isnumeric() for item in my_list): … Read more

[Solved] The function is not returning in clang

Actually, the function returns a value. Maybe you want to see it, so just print the result: #include <stdio.h> #include <cs50.h> int calcrectarea(int len,int wid){ return len*wid; } int main(){ printf(“enter length here:\n”); int x; scanf(“%d”,&x); printf(“enter width here:\n”); int y; scanf(“%d”, &y); printf(“area is: %d”, calcrectarea(x,y)); } solved The function is not returning in … Read more

[Solved] How can I overlap goroutines?

If you need such sequencing, you might reevaluate your need to use goroutines. However, the way you described the solution is correct: go first() { for { <-ch1 // do stuff ch2<-struct{}{} } }() go second() { for { <-ch2 // do stuff ch3<-struct{}{} } }() go third() { for { <-ch3 // do stuff … Read more

[Solved] A Random Wikipedia Article Generator

According to: https://en.wikipedia.org/wiki/Wikipedia:Special:Random The endpoint for a categorized random subject is: https://en.wikipedia.org/wiki/Special:RandomInCategory/ And not: https://en.wikipedia.org/wiki/Special:Random/ So you should change your url to: url = requests.get(f”https://en.wikipedia.org/wiki/Special:RandomInCategory/{topic}”) 1 solved A Random Wikipedia Article Generator

[Solved] Function overloaded by bool and enum type is not differentiated while called using multiple ternary operator in C++

That is because the ternary operator always evaluates to a single type. You can’t “return” different types with this operator. When the compiler encounters such an expression he tries to figure out whether he can reduce the whole thing to one type. If that’s not possible you get a compile error. In your case there … Read more

[Solved] How to add query to my URL? [closed]

@lily … saw your message before I left. This code will create a file. Hope this sorts you out đŸ™‚ <form action=”#” method=”post”> Number start:<br> <input type=”text” name=”num_start” value=”1″> <br> Number end:<br> <input type=”text” name=”num_end” value=”5″> <br><br> <input type=”submit” value=”Submit”> </form> <?php try{ if (isset($_POST[‘num_start’]) && isset($_POST[‘num_end’])){ $i = $_POST[‘num_start’]; $e = $_POST[‘num_end’]; while ($i … Read more