Need help on solving an issue with some code for my class

code.org problem solving process
activity guide - using the problem solving process answer key
problem solving techniques
role of software in problem solving
activity guide - using the problem solving process birthday guests answers
software problem solving techniques
methods of problem solving
problem solving activities classroom

I need to create a program for my python instructor that processes a name and outputs it in the format "Last, First". The 2 different ways the user can input their name are, "first last"(no comma), or "last, first".

I've used my Python book but it does not help much when it comes to what the instructor wants from us to create.

 space = name.index(' ')
 first = name[0:1].upper()+name[1:space]

 comma = name.index(',')
 last = name[0:1].upper()+name[1:comma]

 print(last + ', ' + first)

The correct result of this program should be "Last, First" as I stated already above. I keep getting the first name entered and the output is "name, name," (name is whatever is being inputted into the input statement) example.) user input --> 'joe bob' output --> 'Joe, Joe,'

The mistake you did was first and last were assigned the same string.

I would suggest doing something like this:

name = 'Bob, joe'
if ',' in name:
    last, first = name.split(',')
else:
    first, last = name.split(' ')

print(last.strip().capitalize()  + ', ' + first.strip().capitalize())

Hope this helps.

The Problem Solving Process, This lesson introduces the formal problem solving process that the class will they are good at solving, then a problem they want to improve at solving. the course in some real-life experiences they already have solving problems. A structured problem solving process will be an important tool for helping students move� For more details on inviting users to a class, go to Invite students to a class or Invite teachers to a class. My students have problems with the class code If your class code doesn’t work, you can reset it and give the new code to your students.

You can do something like this:

name = input("Write a name: ")

space_idx = name.index(' ')

if "," in name:
    print(name)
else:
    name = name[space_idx+1:] + ", " + name[:space_idx]
    print(name)

4 steps to solving any software problem – O'Reilly, Problem-solving is a key skill for students, new programmers, and those who That's why, whenever I'm helping beginners learn to code, I try to walk You're trying to figure out some cryptic section of a legacy code base when the mistake: a syntax error, forgetting to pass all the variables you need into� Having a specific project you want to work towards and solving all the little problems on the way will help you learn to code more than just picking up a random Java or C++ book and reading from

In Python3, you can use the split() method to convert a string into a list of words, separated by spaces.

This can be done by words = name.split().

Now, assuming that you have already learned string manipulation, you can remove the comma from the end of the first name (if there is), the first word in the words list.

Then, simply print the list for first name and last name.

Good luck!

5 Tips – How to Teach Students to Solve Word Problems, Removing the distraction of the numbers helps students focus on the situation of the problem and Do you want a free sample of the word problems I use in my classroom? At some point, we do create a list of words, but not a keyword list. Hint: Look at the code used for the problem type in the lower right corner. Copying and pasting code—whether from Stack Overflow, a tutorial, or elsewhere in your codebase—without understanding what it does. I believe this practice leads to “solving” problems without fully understanding them. That’s not to say any of these resources—Stack Overflow, tutorials, any other examples you find—are bad.

So the simplest way is to user rstrip and split function getting the value in list and print it from index number

name = list(map(str, input().rstrip().split()))

print(name[1], name[0])
print(name[1] + ', '+ name[0])

Input

Firstname Lastname

OutPut

Lastname Firstname
lastname, Firstname

Teaching problem solving: Let students get 'stuck' and 'unstuck', Problem solving skills do not necessarily develop naturally; they need to be They need to be able to identify and apply different strategies to solve these problems. Helping my students grow to be people who will be successful After a few weeks, most of the class understands that the teachers aren't� The Java coding help we offer is the answer to these problems. We will give step by step assignment solution. Feel free to ask anything in Java programming language, java programming assignment, academic assignments, academic paper.

About the AoPS Classroom, Each Art of Problem Solving class is held in the AoPS online classroom. To attend each class, Work with instructors and classmates in real-time, receiving one-on-one help as needed. Run Python code in the classroom in our programming classes. Edit the Students can catch up quickly if they miss some material. Looking out for your assessment answers online? Grab the opportunity to find free assignment answers related to all subjects in your Academic. Browse and find MILLIONS OF ANSWERS from Every Subject to Improve Your Grade.

NBS Special Publication, So you can generate problems that are very easy to solve . I didn ' t want to make that conjecture as strong as it might have seemed , and I am sure sub - classes of problems that have been excluded , but some of the work we have done at that generates difficult problems , you are in a good position to test codes that will � The right problem-solving strategies can make the difference between putting a challenge behind you and wallowing in an endemic issue. Branford and Stein presented the IDEAL problem-solving method in 1984. This easy-to-remember heuristic device represents the 5 steps of this evergreen problem-solving method. IDEAL problem-solvers I-dentify the source of the problem, D-efine its context, E

The Art of Problem Solving Student Honor Code, About the principles students must agree to in order to take an AoPS Online Instead, if you need some assistance with a particular problem, we welcome you � Making decisions can help you move forward in solving your problems, so start by deciding on what to focus on, what needs to get done, and how you will go about doing it. X Research source For example, you might have several problems to solve and need to decide which ones to tackle first.

Comments
  • Thank you for the help, Bill! This is a lot easier to understand then what I had earlier.
  • I forgot to mention that both the first and last name needs to be capitalized, I should have made that more clear earlier. My final output is what it needs to be, but the first letter of each name is not capitalized. I'll try fixing this on my own but if you want to post a fix you can do so and I can check back if I can't figure it out! Thank you though! :)
  • Thank you for your input this really helps me! I'm completely brand new to coding and I'm a high school student taking college classes at a nearby college and Python is one of them. So the reason why I'm still having trouble with all "simple" issues is just because I'm a noob.
  • @KeghanPettit That's all right, a bit of commitment and effort will help you push through. I'm three years into python, and I'm already doing stuff like neural networks. I suggest codecademy for supplemental learning. Wish you luck!