Questions tagged [if-statement]

12560 questions
1

votes
0

answer
56

Views

Get the evaluation of if statements in Python pdb

I am new to pdb. I use python3 -m pdb myscript.py in the command line interface. I am currently using s to trace code step by step. There are many if statement in the code that I want to know what they are evaluated to while tracing. The way I am doing now is p if-statement-that-I-am-interested-in t...
Tai
1

votes
2

answer
85

Views

If logic in Pandas, Python 3

I've got a Pandas Dataframe from which I want to compare two columns and create a new column with a calculation based off the result of the comparison. Logic would be the following: If df['column1']>df['column2'] : df['New column']=(df['column1']+df['column2']) else : df['New column']=(df['column1']...
Salva Tdl
1

votes
0

answer
338

Views

Lambda Calculus function to return TRUE/FALSE without “if”

I'm a new comer to Lambda Calculus & trying to understand its workings via Python code. In Lambda calculus, TRUE, FALSE & IFELSE conditional can be represented as: (I'm using L to stand for Lambda symbol) TRUE = Lx.Ly.x FALSE = Lx.Ly.y IFELSE = Lc.Lx.Ly.((c x) y) Using the above definitions, the fol...
user2018
1

votes
0

answer
52

Views

Incrementing a variable 1 time in a loop for further checking with an if

So I have 2 questions regarding those 2 ifs in my code. So, firstly I want to check if fail is superior to 7, but it doesn't seem to work If the value of the variable fail is superior to 7 it would increment its variable by 1. The way it works is that there is more code behind it which sets up a wor...
1

votes
1

answer
46

Views

Not able to use a list in a if-statement

I'm trying to make a loop that allowed me to retrieve tokenized data values in a list, check if there's stop words inside the tokenized cell value and append it to a new list. # Importing the packages to be used import xlrd from nltk.tokenize import word_tokenize from nltk.corpus import stopwords #...
Andric Png
1

votes
1

answer
79

Views

nginx location block serving two request paths, one needs an extra header

I have a single location block with many configurations, which acts as a proxy cache for multiple APIs. One of the APIs requires one additional config: proxy_set_header Content-type ''; I can't seem to put an if statement anywhere and am aware that if statements. in general and especially in locati...
halfpastjohn
1

votes
0

answer
30

Views

if loop for my google app using handlebar utility

In this code isPendingState returns a true or false value and now I want to check if empObj.Current_Appraisal_State is blank or null then I want to print again Pending. {{~#if (isPendingState)}} Pending {{~^~}} {{~empObj.Current_Appraisal_State}} {{~/...
Hemant Lambat
1

votes
1

answer
48

Views

How do i have python3 search for a specific string in a text file

All I'm trying to do is have the program look for a specific string and if the file contains that string add to a variable and if not just print that it didn't work. But it keeps saying that the string was not found when i know it is in the file. for line in open('/home/cp/Desktop/config'): if 'Per...
lavarockman
1

votes
0

answer
20

Views

Vbulletin non-subscribed users if condition

i need to discuss on a code, as my old some topics contain that kind of event also, i have met a friend on internet who gives me that code, DO SOMETHING HERE this is the condition from bbcode can displayed to thread starter because thread started are automatically subscribed after creating topics, b...
imRelease.com
1

votes
0

answer
1.7k

Views

Trouble with if statements, returning a syntaxerror

I'm programming blackjack and trying to input rules for the dealer. The code I've got is as follows if sum(dealer$cards17){ dealer=stick(dealer) }else{ dealer } This returns an error message Error: unexpected '}' in '}'. In the script it also states 'unexpected token 'sum', expected 'LPAREN'. Not su...
F. Wotton
1

votes
1

answer
55

Views

PHP - Using OR in IF statement with function

I am using OR in if statement While adding OR its not working. Follow the code : if(!exists('vouchers','v_id',$generate_id) OR !exists('vouchers','hash',$generate_hash)) { //Doing something } But when I do only one function call its workes. if(!exists('vouchers','v_id',$generate_id)){//WORK...} exi...
Dani Prime
1

votes
2

answer
38

Views
1

votes
1

answer
1.9k

Views

XML IF ELSE statement

For a Google Shopping feed I need to give Google some variables of products I have. Case: There are 3 Unique Product Identifiers: {manufacturer} {upc} {sku} And one way to say if it's true or false: TRUE The g:identifier_exists should be true of 1 of the 3 identifiers is filled in (not null/empty)....
Senta
1

votes
1

answer
60

Views

R: assign value based on criteria

I am trying to convert test scores from a psychological questionnaire in the first data set to standardized scores (range of percentiles) in another data set The test scores are one score from 9 people that took my questionnaire TestResults
Laura
1

votes
1

answer
227

Views

Shared Preference CANNOT store and read the value with the condition.(Android Studio)

I'm developing an Attendance System. To avoid student helping their friend sign the attendance, I plan to use Shared Preference method to store the student ID, after that will blocking their access when login with his friend ID. But the if else statement seems doesn't read the Shared Preference meth...
user3762557
1

votes
3

answer
79

Views

Loop changing background color with switch in javascript

So I've been trying to make this switch, it's simple in my head. stating a variable 'num' equaling 1 to begin with, setting an 'if' or 'while' statement for when 'num' is equal to 2, the background color of a certain div will change from white to yellow and back in .5 second intervals. My problem I...
Tyler Lancaster
-2

votes
0

answer
224

Views

how to fix my if statement that tries to do something?

ok @T.J. Crowder let me try this again, this is where i think i have narrowed the issue down to. I have 4 files, game.js and ilp.js, package.json and the html doc to allow the game to be played, the ilp.js file is node.js. the game.js works as it should and has no errors, running the ilp.js file has...
sl8t87
1

votes
1

answer
98

Views

R: create function or loop to change values based on two (or more) conditions

As you can probably see from the age of my account, i'm new here. I'm running into problems with creating a function or loop to replace single values in a row, based on 2 or more conditions. Here is my sample dataset: date timeslot volume lag1 1 2018-01-17 3 553 296 2 2018-01...
Androssie
1

votes
2

answer
261

Views

MySQL Trigger IF Statement OR not workign when two conditions match

I'm fairly new to MySQL Trigger sintax and I'm having a problem that I could not find a clear answer anywhere. i have a quite simple IF statment, it enters on the IF, if one OR the other condition is met, but never if both are. i want to have some action going if one field or other field of the upda...
Ijimero
1

votes
2

answer
55

Views

Triggering different functions on click event based on innherHTML

When I load page, change to green button displays. When I click on that button, change to purple button displays. But when I click on the button again (based on innherHTML), expected function(onePurple()) is not triggered, but twoGreen() is triggered. I am trying to execute code based on innerH...
user7331530
1

votes
0

answer
30

Views

Pull Rows Referencing A Formula

I have a Macro to copy/paste rows if a cell in a specific column (Col H) has a value greater or equal than a given date -- Sub test30() Dim LR As Long, i As Long LR = Range('A' & Rows.Count).End(xlUp).Row For i = 2 To LR If Range('H' & i).Value >= #1/1/2018# Then Rows(i).Copy Destination:=Sheets('S...
Boiler87
1

votes
1

answer
38

Views

Javascript,nodejs: give a “string not found” messege on console.log

The code listed below searches for files that contains a specified string under it's directory/subdirectories. to activate it, you type node [jsfilename] [folder] [filename] [ext] i would also like it to announce: Nothing found in a console.log every time that a word wasn't found. ive tried if (!re...
Anatsu
1

votes
1

answer
32

Views

Popup modal to not be jumpy

I created a popup modal with Jquery and I have three questions about it. Right now I have the popup to close on click with the button but I also want it to close when clicking outside of the popup. When the user close the popup in the middle of the page, I want the page to stay where it is and not...
skyeyl
1

votes
1

answer
198

Views

compare values from consecutive rows in R

I have a datatable and for each datatable$Ppt and each datatable$nitem, when there is 'fffword' in datatable$Region, I need to extract the value of 'fffword' and compare it with the value of the following 'word'. If the two values are the same, then I need a value of 0 in datatable$Output, if the tw...
dede
1

votes
2

answer
39

Views

How to find all files with the same basename within an IF statement using Unix

In the code below, I have an if statement attempting to exit the program if the user inputs 'safe_rm' as an argument. However it does not account for files with the same name in other directories. How can I improve the code so it does? for i in $* do if [[ 'safe_rm' = $i ]] then echo 'Attempting t...
RacketyGnome300
1

votes
1

answer
156

Views

Array subscript out of bouds in an IF statement

Below is a section for my code. The user inputs a value for Energy, if the value is on the array ARRDAT(1,x), then I want it to assign the related variables ARRDAT(2,x), ARRDAT(3,x), and ARRDAT(4,x). If the data is not on the array, I will interpolate (note: only values between two of my given point...
Chris
1

votes
1

answer
22

Views

If statement for directory starting with specific character

I have a script in which I call R and depending on the directory I specify I want it to carry out a different process. One directory starts with L and the other with S. I have numerous directories that either start with L or S and they all end differently. I specify the directory in bash and run a s...
Walshe_d
1

votes
1

answer
33

Views

How can I use an if statement within or outside of a switch statement (C++)

I am brand new to programming and am doing coding challenges found from here http://www.cplusplus.com/forum/articles/12974/. I cannot find the answer to my specific question through google searches, this is my first time posting here so I apologize if I've broken any guidelines! I am looking at the...
Taelle Echon
1

votes
1

answer
58

Views

Dataframe calculation, anchor cell value to formula

I would like to do some calculations with the following dataframe. There are some values in specific cells of a column, and I would like to have them replicated based on a second column value, and store these in a new, third column: x
BAlpine
1

votes
1

answer
50

Views

how to create active/inactive status using an if-then statement and looping through all rows VBA/Excel

I am trying to create a project management macros and I have coded many parts of it, but I am having trouble with the last piece below. Each task has a start date (Column D), end date (Column E),and a status (Column K). My initial goal was to check if any of the days within 'this week' would fall w...
Taryn Talley
1

votes
2

answer
102

Views

pig latin practice on vb

I am a newb practising vb code by attempting a piglatin translator. I'm stuck on the part where I need to send any consonant letters to the back of the word and loop this process until the first letter becomes a vowel. For example, dragon--> loop once Ragond--> loop again Agondr--> the first word i...
user9395865
1

votes
1

answer
55

Views

How would I make a Generator that generates 1 ____ every __ seconds in my run method without using Thread.sleep()?

Right now, this is the code that I have: @Override public void run() { init(); int fps = 60; double timePerTick = 1000000000 / fps; double delta = 0; long now; long lastTime = System.nanoTime(); long timer = 0; int ticks = 0; makeMaps(); makeTeams(); boolean madeIron = false, madeGold = false, madeD...
1

votes
2

answer
85

Views

How can I rewrite my if-statements to work?

So what the program should basically do is we input filename -i input.txt -o output.txt -c in the command line (command line arguments (argc and argv)) and the program should read the inputfile, count how many words there are, and if there is -c it should convert all of uppercases to lowercases and...
MidnightMoon
1

votes
1

answer
28

Views

Repeat one particular case statement on invalid output condition and loop inside the case

I have a case statement like 1) 2) 3) ... as below where there are multiple if else condition on 1) format case. I want to repeat the particular case on invalid condition. When user select 1 first it ask for the name of the juice. next it asks the availability. If yes it continues else asks for the...
Leo Thomas
1

votes
2

answer
26

Views

How can I truncate these code blocks into one nested for loop?

I have 4 code blocks that take values from a row and do offsets +1, +2, +3, +4 and multiply the values under those cells (span 3 columns). The code takes values I list in Sheet 2 and updates based off the rIterator variable (unique keys that show only what I need to update). After I get the initia...
nick lanta
1

votes
1

answer
27

Views

Excel nested if statements - need help troubleshooting

I need some fresh eyes. I have been working on this incrementally and go from having it work to broken. At this point my eyes are crossing and I could use some help. Column H in this spreadsheet contains a machine id and column I is a date. I want it to display nothing if both H and I are blank...
Doghouse308
1

votes
1

answer
26

Views

How to get a specific index of a string?

Im currently working on something in JAVA, and i was wondering what is the best way to get a specific index of characters within a string.. Lets say I want to check something like that : Saturday - 14:00 GMT: Light Cloud, 3°C (37°F) How can I check the specific index of the String (GMT) to pass it...
Loizos Vasileiou
1

votes
1

answer
541

Views

Index Small and If in Excel for multiple criteria

Hi All I have been trying to use the formula below and to alter it for multiple conditions {=INDEX($C$1:$C$51,SMALL(IF($A$1:$A$51='Adeline',ROW($A$1:$A$51),''),3),1)} I have a table on sheet1 called Data and a page for calculations. There is a matching ID on both sheets though in the table on sheet1...
Mark Larigo
1

votes
1

answer
809

Views

R - is.na() within ifelse()

I am trying to create a new variable child_or_adult in my data set titanic, by using mutate(). The new variable would specify the age group of each person. However, the variable age contains NAs values, which I don't want to ignore. Instead, I want to classify them as adult. How could I do this by u...
Reeza
1

votes
1

answer
20

Views

If statement seems to fail even though it prints a contradictory message

$(document).ready(function(){ $(document).on('keydown', null, 'down', function(){ var leftPaddleRef = document.getElementById('leftPaddle'); if (leftPaddleRef.style.top >= '100') { alert(leftPaddleRef.style.top); } else{ $('#leftPaddle').animate({ top: '+=3%' }, 'fast' ); } }); }); ^ This ^ is my s...
Linooos

View additional questions