Python functions not running correctly

Advertisements I’ve written this code to convert a string to uppercase and lowercase, however when I call my functions, it doesn’t run. # take the input for the string string = input("Enter any string: ") def string_upper(up): return up.upper() print("Uppercase Output: ", string_upper(string)) def string_lower(low): return low.lower() print("Lowercase Output: ", string.lower(string)) if __name__ == "__main__":… Read More Python functions not running correctly

Operator function defaults to first if statement in JavaScript calculator project

Advertisements I’m creating a calculator with JavaScript and most functions are working properly, but the operator function defaults to the first if statement each time (I switched add with subtract to test this). i.e. if the add function is in the first if statement of my operator function, every operator button will add the numbers… Read More Operator function defaults to first if statement in JavaScript calculator project

Error 'listaCliente' undeclared (first use in this function)

Advertisements I can’t run the code because it gives the error mentioned in the title, but I declared it in main. I’m stuck for a few hours and I can’t solve this main.c , here is where I declare the "listaCliente" int main() { Cliente* listaCliente = lerBaseDeDados(); menuPrincipal(listaCliente); } Cliente.c // menu , basically… Read More Error 'listaCliente' undeclared (first use in this function)

passing argument 1 and 2 of ‘strcmp’ makes pointer from integer without a cast [-Wint-conversion]

Advertisements Hello so I’ve been working a little prgramme which is sort of a calculator (I’m a beginner) and well as you can see in the tittle at then end of the code, the two if strcmp doesn’t work. And vscode is telling me (for the strcmp) Exception has occurred. Segmentation fault. But gcc is… Read More passing argument 1 and 2 of ‘strcmp’ makes pointer from integer without a cast [-Wint-conversion]

Why is the std::vector not giving any outputs in c++

Advertisements I don’t understand why but the std::vector is not giving anything after i put a class pointer in the array. // runs at start void States::AssignState(GameState* state) { _nextVacentState++; _states.push_back(state); } // executes in a loop void States::ExecuteCurrentState() { // protection incase there is nothing in the array or the current state is not… Read More Why is the std::vector not giving any outputs in c++

Understanding string variable substitution in a python list comprehension

Advertisements I am not sure on the syntax being used in a list comprehension example in the Python Cookbook. Code (with my print statements in) is below: import html # to accept any number of KEYWORD arguments, use ** # treat the argument as a dictionary def make_element(name, value, **attrs): print(f"attrs has type {type(attrs)}") print(f"attrs… Read More Understanding string variable substitution in a python list comprehension