Python Forum
Instructions unclear - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Instructions unclear (/thread-14206.html)



Instructions unclear - pySpy - Nov-19-2018

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:])



RE: Instructions unclear - Gribouillis - Nov-19-2018

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()