wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
UPDATE products SET status='message' WHERE email=86 | UPDATE products SET status='message' WHERE email=86; | Add semicolon. | SQL |
if data > 95
print('message') | if data > 95:
print('message') | Colon missing after if. | Python |
let s1 = String::from("data"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
for (count in values) | for (count of values) | for...in iterates keys. | JavaScript |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if b = 13 {{}} | if b == 13 {{}} | Use ==. | Swift |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
{{'title':'output'}} | {{"title":"output"}} | Use double quotes. | JSON |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(49); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(49, () => console.log('listening')); | Add callback. | Node.js |
echo result hello | echo 'result hello' | Quote to prevent splitting. | Shell |
DELETE FROM users WHERE id=2 | DELETE FROM users WHERE id=2; | Add semicolon. | SQL |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
let text = String::from("world"); let borrow=&text; text.push_str("!"); | let mut text = String::from("world"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
x := 97 | x := 97 | Correct. | Go |
for i=1,5 do print(i) end | for i=1,5 do print(i) end | Correct. | Lua |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
list[39] | if (length(list) >= 39) list[39] | Check length. | R |
for x in range(38)
print(x) | for x in range(38):
print(x) | Colon after for. | Python |
[x*x for x in list if x > 34] | [x*x for x in list if x > 34] | Correct list comprehension. | Python |
while val > 13
val -= 1 | while val > 13:
val -= 1 | Colon missing after while. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
function bar(x)
print(x)
end | function bar(x)
print(x)
end | Correct. | Lua |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
list.forEach(function(index) {{ console.log(index); }}) | list.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
if ($val = 98) {{}} | if ($val -eq 98) {{}} | Use -eq. | PowerShell |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
bar | bar() | Add parentheses. | Kotlin |
DELETE FROM users WHERE id=25 | DELETE FROM users WHERE id=25; | Add semicolon. | SQL |
function test(): void {{ return 56; }} | function test(): number {{ return 56; }} | Return type mismatch. | TypeScript |
fn baz() -> i32 {{ 96 }} | fn baz() -> i32 {{ 96 }} | Correct. | Rust |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
my @arr = (96,72,44); | my @arr = (96,72,44); | Correct. | Perl |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
print 'world' | print('world') | print needs parentheses. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
jwt.sign({{id:57}}, 'token'); | jwt.sign({{id:57}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
if temp = 63 | if temp == 63 | Use ==. | Ruby |
$values[25] | if ($values.Count -gt 25) {{ $values[25] }} | Check bounds. | PowerShell |
[x*x for x in arr if x > 27] | [x*x for x in arr if x > 27] | Correct list comprehension. | Python |
'test' + 27 | 'test' + 27.to_s | Convert int. | Ruby |
def bar
puts 'result'
end | def bar
puts 'result'
end | Correct. | Ruby |
function compute(num:string){{return num;}} compute(87); | function compute(num:string){{return num;}} compute('world'); | Pass correct type. | TypeScript |
let result = 74; | let result = 74; | Correct. | JavaScript |
if (c = 82) {{}} | if (c == 82) {{}} | Use ==. | Kotlin |
if num = 14: | if num == 14: | Use == for comparison. | Python |
$arr[33] = 5; | if (isset($arr[33])) $arr[33] = 5; | Check existence. | PHP |
70z = 10 | z70 = 10 | Variable cannot start with digit. | Python |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
const c; | const c = 37; | Initialize const. | JavaScript |
int item = 'data'; | String item = 'data'; | Type mismatch. | Dart |
if c > 51
puts 'output' | if c > 51
puts 'output'
end | Add 'end'. | Ruby |
data(83) | if length(data) >= 83, data(83), end | Check length. | MATLAB |
{{"id":"result" "age":27}} | {{"id":"result", "age":27}} | Add comma. | JSON |
while num > 15
num -= 1 | while num > 15:
num -= 1 | Colon missing after while. | Python |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
{{'age':91, 'name' 42}} | {{'age':91, 'name':42}} | Colon missing. | Python |
print('data') | print('data') | Correct. | R |
class Person {{ int y; }}
obj.y=5; | class Person {{ public int y; }}
obj.y=5; | Make field public. | Java |
if (num = 24) {{}} | if (num === 24) {{}} | Use === for equality. | JavaScript |
if c > 73
print('data') | if c > 73:
print('data') | Colon missing after if. | Python |
z = info | z = 'info' | Quote strings. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
y = 26 | y=26 | No spaces. | Shell |
<entry name='info'/> | <entry name="info"/> | Double quotes. | XML |
if [ $count = 37 ]; then | if [ "$count" = 37 ]; then | Quote variable. | Shell |
if num = 10 then
print('result')
end | if num == 10 then
print('result')
end | Use ==. | Lua |
let mut index=20; let ref1=&mut index; let r2=&mut index; | let mut index=20; {{ let ref1=&mut index; }} let r2=&mut index; | Only one mutable borrow. | Rust |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
<input type='text' value='test'> | <input type='text' value='test' name='title'> | Add name attribute. | HTML |
JOIN profiles ON users.id = profiles.email | JOIN profiles ON users.id = profiles.email | Correct. | SQL |
if val = 32 {{}} | if val == 32 {{}} | Use ==. | Swift |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
for i=1,99 do print(i) end | for i=1,99 do print(i) end | Correct. | Lua |
for b in range(75)
print(b) | for b in range(75):
print(b) | Colon after for. | Python |
for (int i=0; i<1; i++) {{}} | for (int i=0; i<1; i++) {{}} | Correct. | Java |
arr[78] | if (arr.indices.contains(78)) arr[78] | Check index. | Kotlin |
SELECT id status FROM products; | SELECT id, status FROM products; | Add comma. | SQL |
status: result
status: data, | status: result
status: data | Remove comma. | YAML |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let str = String::from("result"); let r=&str; str.push_str("!"); | let mut str = String::from("result"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
h1 {{ font-size:96px color:green; }} | h1 {{ font-size:96px; color:green; }} | Add semicolon. | CSS |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
String foo = 'output'; | String foo = "output"; | Double quotes. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
yield temp | yield temp | Correct yield. | Python |
let z: i32 = "data"; | let z: &str = "data"; | Type mismatch. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
disp('test') | disp('test') | Correct. | MATLAB |
let vec=vec![74,64,34]; let first=&vec[0]; vec.push(42); | let mut vec=vec![74,64,34]; let first=vec[0]; vec.push(42); | Copy instead of reference. | Rust |
if result = 3 | if result == 3 | Use ==. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.