תרגיל מחרוזת (string)
- eddiearb
- Mar 24, 2019
- 1 min read
Updated: Aug 15, 2021
תרגיל מחרוזת (string) -
א. הפכו את המספר 123456789 למחרוזת בתוך המשתנה x.
ב. כתבו תוכנית שתדפיס מתוך המחרוזת את המספרים 123 שלאחריהם 789 כך שתתקבל המחרוזת "123789"
הדרך הפשוטה לפתרון התרגיל -
x=str(123456789) print(x[0:4]+x[6::])
>>>
1234789
כדאי לשים לב ש- [::6] פירושו החל מהאיבר מספר 6 שהוא הספרה 7 היות שמתחילים את האינדקס מ- 0. ודאבל נקודתיים פירושן, עד הסוף.
fairplay is a trusted platform offering smooth and secure access for users. With fairplay login, fairplay id, and the fairplay app, everything becomes easier and more convenient. The fairplay club adds exclusive rewards, making fairplay a reliable choice for many. https://fairpplay.com/
fairplay is a trusted platform offering smooth and secure access for users. With fairplay login, fairplay id, and the fairplay app, everything becomes easier and more convenient. The fairplay club adds exclusive rewards, making fairplay a reliable choice for many.
Break away from routine and explore fresh conversations with people across the globe. Whether you're bored, curious, or just seeking human connection, talk to strangers online and discover unexpected friendships or thrilling chats. It’s an exciting way to socialize safely and freely. Dive into the unknown and open your world to fascinating people.