Below is the code i want check:
== }}
Statement;
Statement;
Here _id and ID both are getting passed from route to the handlebar page and now I want to compare them. Thanks!
Below is the code i want check:
== }}
Statement;
Statement;
Here _id and ID both are getting passed from route to the handlebar page and now I want to compare them. Thanks!
I am making a space invaders clone, and I am trying to implement enemy wall collision, but I cant seem to compare all the x coordinates to the wall(I drew all the enemies using turtle and put them in a list) I am getting the error (if enemies_coordinates[i] > -280:IndexError: list index out of range) which confuses me because I am appending the enemies coordinates to the enemies_coordinates list yet it only outputs one. I am probably doing something weird, any help is appreciated.
#FIXME Check the cordainates of all enemies for wall collison
def enemy_coor():
i = 0
for alien in enemies:
global enemies_coordinates
enemies_coordinates = []
enemies_coordinates.append(enemies[i].xcor())
print(enemies_coordinates)
i += 1
#FIXME Wall collioson
def alien_wall_collison():
i = 0
for alien in enemies:
print(i)
if enemies_coordinates[i] > -280:
print("turn Right")
i += 1
Ive created a script to do a certain task to remove a folder before starting a java bot.
However ive run into a problem where the Command Line closes at a certain line because the folders are not there (already deleted).
How can i implement an IF statement to state to do the next task if the File Not Found instead of the CMD closing.
set "bot=%cd%"
echo %USERNAME%
cd C:\Users\%USERNAME%\AppData\Local\Temp
for /f %i in ('dir /a:d /s /b scoped*') do rd /s /q %i
cd %bot%
java -jar Bot.jar
taskkill /F /IM chromedriver.exe
It seems to be closing on this line
for /f %i in ('dir /a:d /s /b scoped*') do rd /s /q %i
as the folders "scoped" have already been removed. I want it to continue to do the next lines if this is the case.
The objective is to create a list comprehension that outputted two values.
The for loops look like below
paper_href_scopus = []
paper_title = []
for litag in all_td.find_all('a', {'class': 'ddmDocTitle'}):
paper_href_scopus.append(litag['href'])
paper_title.append(litag.text)
As suggested by OP, this can be achieved by
paper_href_scopus, paper_title = zip(*[(litag['href'], litag.text) for litag in all_td.find_all('a', {'class': 'ddmDocTitle'})])
However, there is an instances where the all_td.find_all('a', {'class': 'ddmDocTitle'}) return empty and the compiler return an error:
ValueError: not enough values to unpack (expected 2, got 0)
Based on the discussion in this thread, it seems the above code can be modified as
paper_href_scopus, paper_title = zip(
*((litag['href'], litag.text) for litag in all_td.find_all('a', {'class': 'ddmDocTitle'}) \
if all_td.find_all('a', {'class': 'ddmDocTitle'}
))
But still, the compiler return an error
ValueError: not enough values to unpack (expected 2, got 0)
Nevertheless, the following code work despite in some occasion the all_td.find_all('a', {'class': 'ddmDocTitle'}) return empty
[(paper_href_scopus.append(litag['href']), paper_title.append(litag.text)) \
for litag in all_td.find_all('a', {'class': 'ddmDocTitle'})]
But, I would like to avoid using append as there is requirement to initialize paper_href_scopus=[] and paper_title=[] beforehand.
May I know, what can I do to fix the code
paper_href_scopus, paper_title = zip(
*((litag['href'], litag.text) for litag in all_td.find_all('a', {'class': 'ddmDocTitle'}) \
if all_td.find_all('a', {'class': 'ddmDocTitle'}
))
I have come across a weird problem my if and else both are working at the same time and I don't know why is this happening.
Here is the Code
public class RoomChat extends AppCompatActivity {
TextView textviewRoomName;
RecyclerView recyclerView;
DatabaseReference databaseReference, userDetails, dbmessage;
EditText editTextMessage;
ImageButton sendMessage;
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
List<RoomChatModel> messages;
RoomAdapter adapter;
String roomID, senderName, roomName;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_room_chat);
intialiseVariables();
Intent intent = getIntent();
roomID = intent.getStringExtra("roomId");
Log.d("roomId", roomID);
databaseReference = FirebaseDatabase.getInstance().getReference("Rooms").
child(roomID).child("GroupInfo");
dbmessage = FirebaseDatabase.getInstance().getReference("Rooms").
child(roomID);
userDetails = FirebaseDatabase.getInstance().getReference("Users").child(user.getUid());
databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
if (snapshot.exists()) {
roomName = snapshot.child("roomName").getValue().toString();
String roomCode = snapshot.child("roomCode").getValue().toString();
Log.d("Room Name:", roomName);
textviewRoomName.setText(roomName + " ( " + roomCode + " )");
}else {
Toast.makeText(RoomChat.this, "Error Occured : Please Try Again Later",
Toast.LENGTH_LONG).show();
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
userDetails.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
senderName = snapshot.child("username").getValue().toString();
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
sendMessage.setOnClickListener(v -> {
sendMessage();
});
readMessage();
}
So, when I execute this code it setText at textviewRoomName and also show Toast message.
Any Help or Suggestion.
#!/bin/bash
read file_name
if [ -w $file_name ]
then
echo yes
else
echo no
fi
This code printing yes even when file doesn't have write permission
I want to have a gender system in what I'm coding, so in dialogue there are pronouns, but since the strings are defined in an if statement they come up blank. Is there a better way to do this?
int gender;
string pronoun;
string pronoun1;
string pronoun2;
string pronouns3;
string namingGender;
cout << "Please enter your gender \n1. Male \n2. Female \n3. Other" << endl;
cin >> gender;
if (gender == 1) {
string namingGender = " saucy sir";
string pronoun = " he ";
string pronoun1 = " him ";
string pronoun2 = " his ";
string pronoun3 = " he's ";
cout << "Have fun playing Insert-Name-Here!" << endl;
}
else if (gender == 2) {
string namingGender = " manseva madam";
string pronous = " she ";
string pronou1 = " her ";
string pronoun2 = " her ";
string pronoun3 = " she's ";
cout << "Have fun playing Insert-Name-Here!" << endl;
}
else if (gender == 3) {
string nammingGender = " majestic mate";
string pronoun = " they ";
string pronoun1 = " them ";
string pronoun2 = " their ";
string pronoun3 = " they're ";
cout << "Have fun playing Insert-Name-Here!" << endl;
}
else {
cout << "You did not enter 1 2 or 3...guess your other than" << endl;
string nammingGender = " majestic mate";
string pronoun = " they ";
string pronoun1 = " them ";
string pronoun2 = " their ";
string pronoun3 = " they're ";
cout << "Have fun playing Insert-Name-Here!" << endl;
}
cout << "By the way, what is your name... " << namingGender << "?" << endl;
cin >> playerName;