Apply function to each element of a list

I think you mean to use map instead of filter: Even simpler, you could use str.upper instead of importing from string (thanks to @alecxe): In Python 2.x, map constructs a new list by applying a given function to every element in a list. filter constructs a new list by restricting to elements that evaluate to True with a given function. In Python 3.x, map and filter construct iterators instead of lists, so … Read more

Output single character in C

yes, %c will print a single char: also, putchar/putc will work too. From “man putchar”: EDIT: Also note, that if you have a string, to output a single char, you need get the character in the string that you want to output. For example:

Fatal error: iostream: No such file or directory in compiling C program using GCC

Neither <iostream> nor <iostream.h> are standard C header files. Your code is meant to be C++, where <iostream> is a valid header. Use a C++ compiler such as clang++ or g++ (and a .cpp file extension) for C++ code. Alternatively, this program uses mostly constructs that are available in C anyway. It’s easy enough to convert the entire program to compile using a C compiler. Simply remove #include … Read more

How to animate GIFs in HTML document?

By default browser always plays animated gifs, and you can’t change that behavior. If the gif image does not animate there can be 2 ways to look: something wrong with the browser, something wrong with the image. Then to exclude the first variant just check trusted image in your browser (run snippet below, this gif definitely … Read more