I just got started in Python programming. This week, we’ve been learning basic commands such as for, while, if and else. The point is that I got stuck at a point of the following exercise: I am to design a programme which has to ascertain whether the day entered by the user is Monday – ..
I’m working with Pandas. I need to create a new column in a dataframe according to conditions in other columns. I try to look for each value in a series if it contains a value (a condition to return text).This works when the values are exactly the same but not when the value is only ..
Hi please find my code below: def isIn(char, aStr): #char: a single character #aStr: an alphabetized string #returns: True if char is in aStr; False otherwise length=len(aStr) print(length, aStr) #check if length == 0: return False elif length == 1: if char == aStr: return True else: return False elif char==aStr[int(length/2)]: return True elif char<aStr[int(length/2)]: ..
for i in range(len(words)): ttuple=words[i] # ttuple2=words[i-1] # if ttuple%ttuple2!=0: # bbb=bbb+"n" fish_list =  read_operation = open(r’C:UserspiotrPycharmProjectsimportDataryby.txt’, encoding="utf-8") lines = read_operation.readlines() for line in lines: fish_list.append(line.strip().casefold()) for fish in fish_list: print(repr(fish)) if fish in ttuple: print("ccccccccccccc"+fish.strip()) print("aaaaaaaaaaa" + str(ttuple)) What happend here? When I compare in is like if aaa!=ttuple value if fish is ..
I am attempting to make the python code to stop sending to the main_branch and instead keep searching for the exact branch that is located within it’s own region. The problem is that code only sends it to the branch when the branch is ‘open'(or in another easy term is live), but when the branch ..
I want my loop to work fine, hope someone can help me and try to run the code. I’m making a blackjack game to find the probability of certain hands winning or not. I have a while loop to cycle through one full deck of 52 cards that have been shuffled. Within that, I have ..
6 random numbers from 1 to 10(they must be all different) and if the input is in the list of random number "you won" should be printed, but it doesn’t happen. This is what I have: import random numbers=range(1, 11) r=input("Chose your number from 1 to 10 ") a=random.sample(numbers, k=6) print(a) if r in a: ..
#>>>>>>>>>WHEN VOMITING…… Apply 5C’s if ‘vomiting’ in Pres_Comp: Course_V = input(‘Tell me about the vomiting’ +’….’+’When did the vomiting begin?’) Cause_V = input(‘Any idea what might be responsible for the vomiting?’) dete_P = False if ‘yes’ in Cause_V: dete_cause = input(‘What do you think might be responsible for causing the vomiting? ‘) if ‘poison’ or ..
I am not sure whether this question was asked in a similar way in the past, but I didn’t find an answer specific enough for me to understand it. I tried to check values of a dictionary within a for loop with an if statement that has multiple conditions. First I tried this code which ..
I am trying to make an adventure game with checkpoints in python leading back to a certain point in the game when you lose, get an answer wrong or to play again but it keeps bring me back to the wrong point or looping some sections over and over again. I’m not sure what to ..