62,188 questions
-1
votes
1
answer
27
views
Input in if statements are hard
I have a question ovi, my question is about input() how do I make a input on a if statement block and make it about it for example a heads and tails game.
0
votes
0
answers
23
views
Why is <c:if test="#{MyBean.myFunction()}"> rendering multiple times in my xhtml file?
I have a large xhtml file, below the imports there is a component that should only render when a test from a Bean returns true.
<c:if test="#{MyBean.myFunction()}">
<div id=&...
-6
votes
1
answer
116
views
Using for loop to find a common value for every time another common value appears
import pandas as pd
a=1
b=2
c=3
for n in range(10, len(df)-1):
if df.loc[n].isin([a]).any() and df.loc[n].isin([b]).any() :
for x in range(0, ...
1
vote
2
answers
99
views
Why does adding an subsequent if-else block cause another previous if-else block to return nil?
I am a beginner in Ruby and I am having trouble with if else statement. As you know, Ruby will return the last calculated code if the return keyword is not specified.
Here is the issue.
def aMethod(*...
0
votes
1
answer
105
views
If/else statement not processing in Button onClickListener
Is there an obvious reason why an if-else statement would not be processed in a button's onCLickListener()?
I have a HomeScreen Widget with a Settings Activity incorporated.
In there, there is a ...
2
votes
4
answers
128
views
How to find a common value using if statement
I am still a beginner in python. I am trying to find a common value with if statement,
import pandas as pd
df = pd.read_csv("data.csv")
for n in range(2, len(df)):
if df.loc[n].isin([2]...
0
votes
1
answer
45
views
Power Query Concatenate and If statement
I want to add a custom column to concatenate several columns with some if statements. I am getting a "Token 'else' expected error message. Can you please tell me what I forgot or did wrong? Power ...
3
votes
2
answers
154
views
Why does code under a label execute even if I don't branch to it, for an if/else selecting two constants?
I'm learning Assembly through the "Easy 6502 by skilldrick" website.
I have one question. I'm in the part about branching. I wrote the following code:
LDA #$FA
ADC #$01
BCS ...
0
votes
4
answers
206
views
Split function with if statement to define string value (excel vba)
My vba excel code is using split funtion from a combo box value. It takes an ID (alias=GG) which is a value right of the 6th hyphen.
GG = Split(Sheet1.ComboBox1.Value, "-")(6)
example return ...
0
votes
1
answer
90
views
User Friendly Duplicate value message [duplicate]
I want to check to see if value from a form exists in Microsoft Access table using vba or macro that is user friendly but need help putting it together.
I've tried, Private Sub Donor_Key_LostFocus() I ...
0
votes
0
answers
62
views
Why does this count_divisors() function return 0 instead of the divisor count? [duplicate]
I'm trying to solve Project Euler Problem 12 in C++, which is to find the first triangular number with over 500 divisors.
I am currently trying to write a function that counts the number of divisors ...
3
votes
2
answers
273
views
Why does "\0" give integer in c
So, I am learning C language and was trying to make a function that returns the length of a string. In the if statement I mistakenly used "" instead of ''. So, instead of comparing to char '\...
0
votes
2
answers
147
views
How do I assign a value according to conditional statement that use dates from multiple columns [closed]
I am using a large dataset which contains patients with 5 different cancer types. Each patient can have one or more cancer diagnosis, identified in the n.cancers column. There are also columns for ...
1
vote
2
answers
187
views
How do I filter my data with a looped "if" statement while retaining data from both current, past and an average of current + past loops?
I'm currently trying to filter a dataset containing audio data on bird species. The data looks like this:
head(audiomoth_sample)
id
park
park_abbr
am_no
sci_name
com_name
start_s
end_s
conf
date_time
...
1
vote
3
answers
128
views
Excel Range IF fails with an AND
Trying to aggregate a list of names that are overdue. This works great until I add an AND to the IF, then everything falls apart and no results are returned.
I need to aggregate a list of names by ...
3
votes
3
answers
182
views
Reduce nested IF…ELSE conditions that iteratively condition building a query by adding filters one by one
My stored procedure has this structure:
if Count 1>0 then
count 2 with (condition 1,)
if Count 2>0 then
count 3 with (condition 1,2)
if Count 3>0 then
count 4 with(condition ...
3
votes
1
answer
68
views
Assign column status retrospectively in pandas
I have created the following pandas dataframe:
import pandas as pd
import numpy as np
ds = {'col1' : [234,321,284,286,287,300,301,303,305,299,288,300,299,287,286,280,279,270,269,301]}
df = pd....
-4
votes
4
answers
354
views
How to find the longer of two strings without if, switch or ternary?
How to implement a method that receives two strings and displays a message with the longer string and its length, without using if, switch or ternary operators?
4
votes
3
answers
141
views
How do I write an if statement in Excel within a specific time frame
I am looking to show hospital procedure times done out of hours which would be between 19:00pm to 07:59am.
For example a procedure start time at 01:15 should show as "Out of Hours" or "...
2
votes
2
answers
84
views
Elseif function not returning correct answer [closed]
I'm writing code in VBA that will format files.
There are different subs for each file type that should be activated by double-clicking a cell in a worksheet.
The thing is that I'm using elseif ...
0
votes
1
answer
122
views
Is it possible to restrict variable declaration of a type inside an if expression?
Snippet:
struct Foo {
constexpr explicit operator bool() const noexcept { return false; }
};
int main() {
if(auto a = Foo{}) // declaration OK
{
}
auto b = Foo{}; // ...
3
votes
1
answer
96
views
Python While loop is executed, but then it fails to execute an if statement after it
I am working on a simple 2 player dice rolling game and have found a problem that i haven't been able to fix, after a While loop, it refuses to execute an if statement
def Main():
global player1_score,...
0
votes
0
answers
15
views
I can't get result of setx in test and in bat file
I used setx to deine my variable waOk
now in a new cmd i get
C:\Users\Jml>echo %waOk%
ok
C:\Users\Jml>if %waOk% == "ok" (echo ok) else (echo non ok)
non ok
why the "if" doesn'...
0
votes
0
answers
49
views
ACF/PACF for certain time-frame of time-series
I'm trying to analyse acf/pacf plots of industrial production index, using first and seasonal differences to correctly identify SARIMA parameters. Data are stored in "zoo" time-series object ...
4
votes
1
answer
89
views
bash string has odd expansion in if statement
I am doing a simple substring check using vars in .bashrc. This check should prevent adding a new path entry to $PATH that already exists in $PATH. The lhs is fine but the rhs of the compare expands ...
-1
votes
1
answer
69
views
IF percentage statement
Hi, I have a list of percentages in row A, and I want to create a formula that, whenever the percentages don't add up to 100%, an even amount is added to each cell in Column A, and the number is ...
0
votes
1
answer
32
views
for item in example_list - does not seem to to go through every 'item in' or my code is getting stuck when there are multiple of the same value
my function guess_loop only gets the first of duplicate values or its only filling in the first when I print display
if I select B as my first letter it fills in fine but when i select O it only gets ...
2
votes
1
answer
115
views
Excel - Nested IF(AND()) Statements to Report Multiple Parameters
My Objective:
In Excel, I need to identify 'Special' projects. The excel formula already identifies if a project has 'Not Started' and 'Ended,' as well as what year (year 1, year 2, year 3) the ...
-1
votes
2
answers
124
views
How is the defined function used in if statements in perl
currently I am trying to interpret the following line of code: if (! defined $variabletype) {$variabletype = "";}
I am relatively new to perl so while I can guess what this conditional ...
0
votes
1
answer
71
views
Azure devops yaml pipeline if statement check for empty string
We are trying to run a task conditionally, but the condition always seems to be true, even if it shouldn't. We have 3 files that are passing a parameter from the devops variables down to each file:
...
-3
votes
1
answer
85
views
if (a is not 1 and not 2) vs if(a is not 1 and 2)
Straightforward question, how can I differentiate these ifs?
if (a is not 1 and not 2)
{
...
}
and
if (a is not 1 and 2)
{
...
}
As I understand it, first one can be written as if (a != 1 &...
0
votes
0
answers
42
views
String comparison in a makefile: incorrect result
In a makefile I need to check, whether a program rocq exists in the system. If it exists assign one value to the variable, otherwise assign another value.
I created the following code:
OUTPUT=$(shell ...
1
vote
3
answers
172
views
Trying to print second last word but output shows only "L". What's wrong with my Java code? [closed]
A program that prints the second last word of a sentence.
public class secToLast{
public static void main(String args[]){
String gg = "I love India";
int len = gg.length()...
1
vote
1
answer
124
views
Excel - Finding Years (1, 2, or 3) by Nesting a DATEDIF() Statement inside an IF() statement
My Objective: In Excel, I need to find out what year (year 1, year 2, year 3, or ENDED) the project has been and will be through fiscal year (FY)2025 (using dates 10/01/24-09/01/25 for FY25).
Version ...
0
votes
1
answer
91
views
Svelte adds spaces when I start inline conditional on a new line. Any way to prevent this?
I have a Svelte component with logic that's structured like this. See in playground here.
<script>
let a = true
let b = false
</script>
<p>Hover over the asterisk at the end ...
0
votes
1
answer
25
views
adding if statement in a Measure DAX
I am using the following DAX in the measure below:
UPS %No Maint Bypass =
VAR TotalMaintBypass =
COUNTROWS (
FILTER ( ALL ( 'UPS (2)' ), 'UPS (2)'[UPS Maintenance Bypass] = "TRUE"...
1
vote
0
answers
44
views
Trouble using "ifelse" or "case_when" to create indicator variable in for panel data [duplicate]
I am trying to create a indicator variable for panel data flagging "on/before" a certain year and "after". Trying both "ifelse" and "case_when" approaches, I do ...
1
vote
2
answers
75
views
How do I check one column in R for a specific word and overwrite or return that word in another column? [closed]
Using R, I want to check the ManufShortName column and if there is the word 'BLANK', then I want to return the word 'BLANK' in another column named AnalysisNotesCode in the same row.
If there is a ...
-1
votes
1
answer
40
views
Pyautogui only activating when it is the first if statement
Im using pyautogui and detecting multiple images through three if statements. But only the top if statement is activated, even though the other if statements should be true according to previous tests
...
0
votes
1
answer
33
views
Formula returning 1 if sum of Column A is 0, otherwise 0, not working for one specific row
I have a simple sum column and a simple if statement in sum 0 that says "if sum antal=0 then 1 else 0"
But on the last row it returns 0 instead of 1.
I have tried to change the number ...
-1
votes
2
answers
785
views
When should I use switch instead of if in Dart? [closed]
I’m confused about when to use switch vs if in Dart. I want to know which one is better for specific situations and when to choose one over the other.
I tried using both if and switch to check a ...
-2
votes
2
answers
117
views
Why do i need to use rising_edge in this VHDL code? [duplicate]
so what is the difference between these two vhdl programs:
process(clk)
begin
if(clk=1)
q<=d;
end if;end process;
and this one:
process(clk)
begin
if(rising_edge clk)
q<=d;
end if;end ...
0
votes
1
answer
96
views
Using 'if let varName {...}' in Swift when varName is previously declared as a var
Fairly experienced coder here. Here is some Swift code in a playground:
var word : String? = "Hello, World!"
if let word {
print("it is a \(word)")
}
else {
print("The ...
4
votes
4
answers
203
views
How to do multiple if/else logic calculations and apply them to several columns in a dataframe?
Suppose I have a dataframe df in R like this:
A B C D
1.4 4.0 6.0 1.0
2.5 1.5 2.4 2.3
3.0 1.7 2.5 3.4
Say I want to write a function that checks the value of each cell ...
0
votes
1
answer
66
views
Microsoft PowerApps Table Lookup - Navigating to Different Screens Based on User Type
I'm having trouble getting this login page to work. It needs to take the user to a specific page depending on their credentials. There are 3 different tables for the different types of users.
This is ...
0
votes
4
answers
185
views
Can I check the value of the array within a two dimensional array in C
char array[8][13];
memset (&array, 0, sizeof(array));
/* this is a rough example this is in a struct that is memset */
if (array[0])
{
printf("this is valid"); /* again this code is ...
0
votes
1
answer
116
views
Best practices for handling multiple nil/invalid checks without throwing an exception
The following ruby method is expected to return either an array or nil, depending on whether or not the api call was successful.
# @return [Array or nil] - but should not throw error if anything ...
0
votes
0
answers
44
views
If a cell contains 3 different texts then today's date
I am trying to add today's date on a column if that column contains 3 different words. I can do it with 1 word but no with 3 different.
More specific: If B11 contains "Accepted, rejected or ...
-1
votes
1
answer
67
views
How do I make it check if the specific text is put or not with another text?
import time
list = ["@gmail.com", "@yahoo.com", "@outlook.com"]
email = input("Email: ")
time.sleep(1.5)
if email in list:
print(email)
else:
...
1
vote
2
answers
135
views
Dynamically updating and doing math on arrays in Excel
I am dynamically populating an array in Excel from another array in a different sheet based on a criteria and was successful in that but now I wish to auto update the returned total based on another ...