Question

In: Computer Science

So currently I am working on some SQL with python which is linked to my database...

So currently I am working on some SQL with python which is linked to my database and I am stuck on a split problem. So in the program it connects to the database and then next you input either list, add, update, remove or allocate. So lets say I want to add a new data into the database you just need to write: update -name='Ava - #2' -class=2.

After you type this there is a variable called val which does the strip and split.

So as of right now what I have done is:

val = input('> ').strip().lower()
parts = val.split(' ')
print(parts)

So if I input the following: update -name="Nile Adam" -class=2

I expect the following output: ['update', '-name="Nile Adam"', '-class=2']

However the output I get is: ['update', '-name="Nile', 'Adam"', '-class=2']

Solutions

Expert Solution

SOURCE CODE:

*Please follow the comments to better understand the code.

**Please look at the Screenshot below and use this code to copy-paste.

***The code in the below screenshot is neatly indented for better understanding.


# If you want to get it in lower case, use lower() here
val = input('> ').strip()
parts = val.split(' ')

# We can use regex for this problem but it's too complex.

# We can simply go for appending the first and last names as follows
# Get the name here
name = parts[1]+" "+parts[2]

# Create the parts as required
parts = [parts[0], name , parts[3]]

print(parts)

===============================

If you want it in lower case...


Related Solutions

Needs to be coded in Python. Hello i am working on a project for my computer...
Needs to be coded in Python. Hello i am working on a project for my computer programming course and i am having trouble with one part. The code needs to be able to produce two versions of an output given inputs by the user. for instance. Here is the code i have to produce the following output. The input from the user are num1 num2 and asc which is just asking if they want the output to be ascending or...
Working with Python. I am trying to make my code go through each subject in my...
Working with Python. I am trying to make my code go through each subject in my sample size and request something about it. For example, I have my code request from the user to input a sample size N. If I said sample size was 5 for example, I want the code to ask the user the following: "Enter age of subject 1" "Enter age of subject 2" "Enter age of subject 3" "Enter age of subject 4" "Enter age...
Here is a project I am currently working on and I could use some feedback on...
Here is a project I am currently working on and I could use some feedback on how to get started. I calculated the general probabilities for the first two columns of each spreadsheet (successes / total outcomes). I don't want to move forward until I know I'm on the right track but I'm concerned that I've oversimplified the question being asked. I'm also using Excel and am having a hard time finding an appropriate formula for conditional probability. My book...
Need some clarification on the following: I am currently working on an assignment with the following...
Need some clarification on the following: I am currently working on an assignment with the following question: - Identify the commands that are generally causing the highest load on your system and discuss your perspectives on why they cause such a load. Discuss your perspectives on the considerations system administration must give while using these commands. In my research, I can only find linux commands used to identify high loads on a linux system, but as we can see the...
Hi, Working on a project in my group for class and I am having some issues...
Hi, Working on a project in my group for class and I am having some issues My part is current state of the business. It is a store and the annual sales are $460,000 Other info I have is: Ownership and Compensation; Percent Ownership Personal Investment Mitchell George, Founder & CEO 25% $125,000Katie Beauseigneur, COO 15% $75,000 Melissa Dunnells, CFO15% $75,000 Also, a medium coffee price from store is $3.75 Sarah Griffin, Marketing Officer 10% $50,000 Katharina Ferry, HR Director10%...
I am working on an assignment using SQL Server Management and I need to print an...
I am working on an assignment using SQL Server Management and I need to print an ERD to a single page as a PDF file. I am not sure how to do this especially because the diagram is rather large... I am using SQL Server Management Studio I have created an Entity relationship diagram for AdventureWorks that includes all product tables. There are many tables.How do I print it to a single page?
22. I am figuring out some numbers for my retirement and housing costs so I ask...
22. I am figuring out some numbers for my retirement and housing costs so I ask myself the following questions: How much will I have to invest annually to get to a million in 30 years if I think I can earn 7% per year 10,500 21,000 33,333 You wanted to refinance your home as interest rates have dropped and you are thinking of getting a 15 yr mortgage to cut your total interest payments over the life of the...
Please write the SQL statement for the following. I am using the Adventurework2014 database. 1. Create...
Please write the SQL statement for the following. I am using the Adventurework2014 database. 1. Create a login for AdventureWorks employees. An employee login should be composed of the first letter of a person's first name combined with their last name. In addition, the login should be all lower case characters. All the required information is located in Person.Person table. Employees can be identified by "EM" value in the PersonType field. The output should include BusinessEntityID, first name (FirstName), last...
I am working on extensive report for my Advanced Corp. Tax class and I am hoping...
I am working on extensive report for my Advanced Corp. Tax class and I am hoping to get a better understanding of the following: -In order for a corporation to make a valid “S” election, the corporation must be a “small business corporation.” Explain the meaning of “small business corporation” in this context. -Explain what ‘separately stated items’ are in regards to Partnerships and S corporations? Give an example of ‘separately stated items’ for each type of entity. -What requirements...
Hi I am working on my chemistry homework about acids and bases and I am confused...
Hi I am working on my chemistry homework about acids and bases and I am confused on this question from a lab. We used grape juice and cranberry juice and we had to put HCl and NaOH in the test tube full of juice. 1. Referring back to procedure 1 of the experiment, which of the two juices is more useful as a general pH indicator and why? I think it is grape juice but I just don't know what...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT