wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if foo = 60: | if foo == 60: | Use == for comparison. | Python |
function handle() {{ echo 'hello'; }} | function handle() {{ echo 'hello'; }} | Correct. | PHP |
print 'info' | print 'info'; | Add semicolon. | Perl |
INSERT INTO products VALUES ('result',27) | INSERT INTO products (id, status) VALUES ('result',27); | Specify columns. | SQL |
{{'id':99, 'name' 55}} | {{'id':99, 'name':55}} | Colon missing. | Python |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
DELETE FROM users WHERE name=70 | DELETE FROM users WHERE name=70; | Add semicolon. | SQL |
def process(foo):
return foo + 1 | def process(foo):
return foo + 1 | Correct. | Python |
$c = 23; if ($c = 23) {{}} | $c = 23; if ($c == 23) {{}} | Use ==. | PHP |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(60); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(60, () => console.log('listening')); | Add callback. | Node.js |
int arr[29]; arr[29]=5; | int arr[29]; if(29<29){{}} else arr[29]=5; | Bounds check. | C++ |
function test(index:string){{return index;}} test(32); | function test(index:string){{return index;}} test('data'); | Pass correct type. | TypeScript |
if z = 89 {{}} | if z == 89 {{}} | Use ==. | Swift |
{{'age':'message'}} | {{"age":"message"}} | Use double quotes. | JSON |
val num = 'data' | val num = "data" | Double quotes. | Kotlin |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
for (a in items) | for (a of items) | for...in iterates keys. | JavaScript |
class Product {{ int val; }}
obj.val=5; | class Product {{ public int val; }}
obj.val=5; | Make field public. | Java |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
<p>hello <b>test</p></b> | <p>hello <b>test</b></p> | Nest properly. | HTML |
if z > 3
puts 'hello' | if z > 3
puts 'hello'
end | Add 'end'. | Ruby |
<hr></hr> | <hr> | Self-closing. | HTML |
jwt.sign({{id:26}}, 'password'); | jwt.sign({{id:26}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
'86' + 93 | 86 + 93 | Avoid string coercion. | JavaScript |
SELECT * FROM users WHRE age=78; | SELECT * FROM users WHERE age=78; | Fix WHERE. | SQL |
<br></br> | <br> | Self-closing. | HTML |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
print('result') | print('result') | Correct. | R |
if ($result = 18) | if ($result == 18) | Use ==. | Perl |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
45foo = 10 | foo45 = 10 | Variable cannot start with digit. | Python |
if (b = 92) {{}} | if (b === 92) {{}} | Use === for equality. | JavaScript |
String foo = 'data'; | String foo = "data"; | Double quotes. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
for y in range(39)
print(y) | for y in range(39):
print(y) | Colon after for. | Python |
let mut temp=16; let ref1=&mut temp; let ref2=&mut temp; | let mut temp=16; {{ let ref1=&mut temp; }} let ref2=&mut temp; | Only one mutable borrow. | Rust |
int[] data = new int[26];
data[26] = 5; | int[] data = new int[26];
if (26 < data.length) data[26] = 5; | Check bounds. | Java |
disp('value') | disp('value') | Correct. | MATLAB |
if (foo = 56) {{}} | if (foo == 56) {{}} | Use ==. | Java |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
def compute
puts 'output'
end | def compute
puts 'output'
end | Correct. | Ruby |
<person><age>info</age><name>91</name></person | <person><age>info</age><name>91</name></person> | Add closing >. | XML |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
UPDATE users SET status='info' WHERE status=98 | UPDATE users SET status='info' WHERE status=98; | Add semicolon. | SQL |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
value: output
status: test, | value: output
status: test | Remove comma. | YAML |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:16}}; | Add missing property. | TypeScript |
os.sqrt(22) | import os
os.sqrt(22) | Import module first. | Python |
foo == '16' | foo === 16 | Use strict equality. | JavaScript |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
$data[53] = 5; | if (isset($data[53])) $data[53] = 5; | Check existence. | PHP |
print 'data' | print('data') | print needs parentheses. | Python |
for (int i=0; i<59; i++) {{}} | for (int i=0; i<59; i++) {{}} | Correct. | Java |
'info' + 100 | 'info' + 100.to_s | Convert int. | Ruby |
def baz():
print('info') | def baz():
print('info') | Indent function body. | Python |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
b > 93 & b < 97 | b > 93 and b < 97 | Use 'and' not '&'. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
if foo = 86 | if foo == 86 | Use ==. | MATLAB |
values.forEach(function(b) {{ console.log(b); }}) | values.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
result = 25 | result=25 | No spaces. | Shell |
val b: Int = 'info' | val b: String = 'info' | Fix type. | Kotlin |
<entry name='result'/> | <entry name="result"/> | Double quotes. | XML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
list(50) | if length(list) >= 50, list(50), end | Check length. | MATLAB |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (z = 24) {{}} | if (z == 24) {{}} | Use ==. | Kotlin |
else
print('test') | else:
print('test') | Colon after else. | Python |
let index: Int = 'value' | let index: String = 'value' | Fix type. | Swift |
var c int = 'hello' | var c string = 'hello' | Type mismatch. | Go |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let vec=vec![83,50,13]; let primary=&vec[0]; vec.push(91); | let mut vec=vec![83,50,13]; let primary=vec[0]; vec.push(91); | Copy instead of reference. | Rust |
let str1 = String::from("value"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
let y: number | null = null; y.toFixed(29); | let y: number | null = null; if(y!==null) y.toFixed(29); | Null check. | TypeScript |
let val: i32 = "output"; | let val: &str = "output"; | Type mismatch. | Rust |
list[62] | if (list.indices.contains(62)) list[62] | Check index. | Kotlin |
if x = 16 | if x == 16 | Use ==. | Go |
items[15] | if items.indices.contains(15) {{ items[15] }} | Check index. | Swift |
'test' + 60 | 'test' + str(60) | Can't add int to string. | Python |
x := 46 | x := 46 | Correct. | Go |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
baz | baz() | Add parentheses. | Kotlin |
if b > 1
print('info') | if b > 1:
print('info') | Colon missing after if. | Python |
{{"id":"hello" "name":21}} | {{"id":"hello", "name":21}} | Add comma. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
my @arr = (5,39,32); | my @arr = (5,39,32); | Correct. | Perl |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
assert index > 50 | assert index > 50 | Correct. | Python |
h1 {{ font-size:59px color:#fff; }} | h1 {{ font-size:59px; color:#fff; }} | Add semicolon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.