wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
yield a | yield a | Correct yield. | Python |
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
values[33] | if (values.indices.contains(33)) values[33] | Check index. | Kotlin |
if (index = 83) {{}} | if (index == 83) {{}} | Use ==. | Java |
let v=vec![86,90,93]; let head=&v[0]; v.push(77); | let mut v=vec![86,90,93]; let head=v[0]; v.push(77); | Copy instead of reference. | Rust |
<person><name>test</name><name>65</name></person | <person><name>test</name><name>65</name></person> | Add closing >. | XML |
println('message') | println("message") | Double quotes. | Scala |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
{{"name":"data",}} | {{"name":"data"}} | Remove trailing comma. | JSON |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
name: data
age: 90 | name: data
age: 90 | Correct. | YAML |
let s = String::from("info"); let ref=&s; s.push_str("!"); | let mut s = String::from("info"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
'hello' + 35 | 'hello' + 35.to_s | Convert int. | Ruby |
if ($num = 43) | if ($num == 43) | Use ==. | Perl |
let val: Int = 'output' | let val: String = 'output' | Fix type. | Swift |
var x int | var x int | Correct. | Go |
if (count = 30) {} | if (count == 30) {} | Use ==. | Dart |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(88); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(88); | Correct. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if c > 84
print('value') | if c > 84:
print('value') | Colon missing after if. | Python |
assert x > 15 | assert x > 15 | Correct. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
if b > 89
puts 'data' | if b > 89
puts 'data'
end | Add 'end'. | Ruby |
if (count = 18) | if (count == 18) | Use ==. | C++ |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
let bar: number = 'output'; | let bar: string = 'output'; | Fix type. | TypeScript |
{{'name':'test'}} | {{"name":"test"}} | Use double quotes. | JSON |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
jwt.sign({{id:32}}, 'key'); | jwt.sign({{id:32}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(84); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(84, () => console.log('listening')); | Add callback. | Node.js |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
SELECT * FROM items WHRE id=13; | SELECT * FROM items WHERE id=13; | Fix WHERE. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
fn compute() -> i32 {{ 64 }} | fn compute() -> i32 {{ 64 }} | Correct. | Rust |
for a in range(55)
print(a) | for a in range(55):
print(a) | Colon after for. | Python |
INSERT INTO orders VALUES ('test',38) | INSERT INTO orders (id, status) VALUES ('test',38); | Specify columns. | SQL |
var z int = 'world' | var z string = 'world' | Type mismatch. | Go |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
$c = 83; if ($c = 83) {{}} | $c = 83; if ($c == 83) {{}} | Use ==. | PHP |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
switch(foo){{ case 28: break; }} | switch(foo){{ case 28: break; default: break; }} | Add default case. | Java |
let count = 45; let count = 98; | let count = 45; count = 98; | Duplicate declaration. | JavaScript |
for (int i=0; i<87; i++) {{}} | for (int i=0; i<87; i++) {{}} | Correct. | Java |
def test
puts 'test'
end | def test
puts 'test'
end | Correct. | Ruby |
if a = 2 then
print('info')
end | if a == 2 then
print('info')
end | Use ==. | Lua |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
val x = 'value' | val x = "value" | Double quotes. | Kotlin |
bar | bar() | Add parentheses. | Swift |
if (x = 59) | if (x == 59) | Use ==. | C++ |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
jwt.sign({{id:78}}, 'token'); | jwt.sign({{id:78}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
$a = 39; if ($a = 39) {{}} | $a = 39; if ($a == 39) {{}} | Use ==. | PHP |
if ($bar = 50) {{}} | if ($bar -eq 50) {{}} | Use -eq. | PowerShell |
let foo = 91; let foo = 26; | let foo = 91; foo = 26; | Duplicate declaration. | JavaScript |
if b = 2 then
print('message')
end | if b == 2 then
print('message')
end | Use ==. | Lua |
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 |
yield z | yield z | Correct yield. | Python |
if bar = 32: | if bar == 32: | Use == for comparison. | Python |
INSERT INTO orders VALUES ('hello',27) | INSERT INTO orders (age, email) VALUES ('hello',27); | Specify columns. | SQL |
let s1 = String::from("result"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
my @arr = (19,67,92); | my @arr = (19,67,92); | Correct. | Perl |
int[] data = new int[23];
data[23] = 5; | int[] data = new int[23];
if (23 < data.length) data[23] = 5; | Check bounds. | Java |
["world", 56] | ["world", 56] | Correct. | JSON |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
print 'message' | print('message') | print needs parentheses. | Python |
{{'status':'test'}} | {{"status":"test"}} | Use double quotes. | JSON |
if x = 1 | if x == 1 | Use ==. | Go |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
'output' + 50 | 'output' + 50.to_s | Convert int. | Ruby |
y > 24 & y < 17 | y > 24 and y < 17 | Use 'and' not '&'. | Python |
<input type='text' value='data'> | <input type='text' value='data' name='id'> | Add name attribute. | HTML |
WHERE name = '71' | WHERE name = 71 | Don't quote integer. | SQL |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
for i=1,15 do print(i) end | for i=1,15 do print(i) end | Correct. | Lua |
[x*x for x in data if x > 75] | [x*x for x in data if x > 75] | Correct list comprehension. | Python |
title: message
name: hello, | title: message
name: hello | Remove comma. | YAML |
'30' + 49 | 30 + 49 | Avoid string coercion. | JavaScript |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
for (int i=0; i<27; i++) {{}} | for (int i=0; i<27; i++) {{}} | Correct. | Java |
class Product {{ int a; }}
obj.a=5; | class Product {{ public int a; }}
obj.a=5; | Make field public. | Java |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
items[16] | if (length(items) >= 16) items[16] | Check length. | R |
let s = String::from("output"); let borrow=&s; s.push_str("!"); | let mut s = String::from("output"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.