Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Instructions unclear
#1
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:])
Reply
#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()
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020