Python Forum

Full Version: Instructions unclear
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey everyone, I have some code here that I just wrote for a course I am taking
in computer science. The instructions are, "Given the variables s and t defined as
s = udacity; t = bodacious; Write python code that prints out 'udcaious' without
using any quote characters in your code.
My Code:

s = 'udacity'
t = 'bodacious'

grab_u = s.find('u')
grab_dacious = t.find('dacious')
the_answer = s[grab_u] + t[grab_dacious:]
print(the_answer)
Note: This isn't actual homework, as I am still a student in school. I'm about to get my
high school diploma and I'm just studying up on computer science before I take it in college
next year. Im giving a good 4+ hours a day into studying computer science just to have a
headstart before next year.

## Solved ##

Realized I had to use the slice notation, in the above post I had ' "" ' inside
of my variables which wasn't allowed.

s = 'udacity'
t = 'bodacious'
 
print(s[0] + t[2:])
You can start with
s = bytes([117, 100, 97, 99, 105, 116, 121]).decode()
t = bytes([98, 111, 100, 97, 99, 105, 111, 117, 115]).decode()