wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
{{'title':'data'}} | {{"title":"data"}} | Use double quotes. | JSON |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
WHERE id = '87' | WHERE id = 87 | Don't quote integer. | SQL |
val index = 'hello' | val index = "hello" | Double quotes. | Kotlin |
process | process() | Add parentheses. | Kotlin |
if ($val = 14) | if ($val == 14) | Use ==. | Perl |
if (z = 5) {{}} | if (z === 5) {{}} | Use === for equality. | JavaScript |
[x*x for x in values if x > 27] | [x*x for x in values if x > 27] | Correct list comprehension. | Python |
for y in range(89)
print(y) | for y in range(89):
print(y) | Colon after for. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
let temp = 51; let temp = 10; | let temp = 51; temp = 10; | Duplicate declaration. | JavaScript |
let temp: number | null = null; temp.toFixed(32); | let temp: number | null = null; if(temp!==null) temp.toFixed(32); | Null check. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if foo = 85: | if foo == 85: | Use == for comparison. | Python |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
let text1 = String::from("data"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
DELETE FROM orders WHERE id=98 | DELETE FROM orders WHERE id=98; | Add semicolon. | SQL |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
SELECT * FROM items WHRE name=19; | SELECT * FROM items WHERE name=19; | Fix WHERE. | SQL |
.Product {{ color: green; }} | .Product {{ color: green; }} | Correct. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
String data = 'result'; | String data = "result"; | Double quotes. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
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 |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
class User {{ int val; }}
obj.val=5; | class User {{ public int val; }}
obj.val=5; | Make field public. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
render | render() | Add parentheses. | Swift |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(41); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(41, () => console.log('listening')); | Add callback. | Node.js |
let index = 21; let index = 41; | let index = 21; index = 41; | Duplicate declaration. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if index = 4 then
print('output')
end | if index == 4 then
print('output')
end | Use ==. | Lua |
print 'result' | print 'result'; | Add semicolon. | Perl |
class Product {{ int bar; }}; | class Product {{ public: int bar; }}; | Make public. | C++ |
if (y = 9) {{}} | if (y == 9) {{}} | Use ==. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
my @arr = (26,38,80); | my @arr = (26,38,80); | Correct. | Perl |
def compute
puts 'hello'
end | def compute
puts 'hello'
end | Correct. | Ruby |
val b: Int = 'data' | val b: String = 'data' | Fix type. | Kotlin |
SELECT id status FROM products; | SELECT id, status FROM products; | Add comma. | SQL |
z > 24 & x < 23 | z > 24 and x < 23 | Use 'and' not '&'. | Python |
var x int | var x int | Correct. | Go |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
SELECT * FROM items WHRE age=56; | SELECT * FROM items WHERE age=56; | Fix WHERE. | SQL |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
if (index = 42) {{}} | if (index == 42) {{}} | Use ==. | Kotlin |
function process() {{ echo 'info'; }} | function process() {{ echo 'info'; }} | Correct. | PHP |
function compute() {{
return
{{key:'result'}}
}} | function compute() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
DELETE FROM products WHERE id=5 | DELETE FROM products WHERE id=5; | Add semicolon. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
switch(count){{ case 81: break; }} | switch(count){{ case 81: break; default: break; }} | Add default case. | Java |
function compute(a)
print(a)
end | function compute(a)
print(a)
end | Correct. | Lua |
if z = 19: | if z == 19: | Use == for comparison. | Python |
h1 {{ font-size:86px color:#333; }} | h1 {{ font-size:86px; color:#333; }} | Add semicolon. | CSS |
item = 89 | item=89 | No spaces. | Shell |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
let vec=vec![82,16,27]; let first=&vec[0]; vec.push(25); | let mut vec=vec![82,16,27]; let first=vec[0]; vec.push(25); | Copy instead of reference. | Rust |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
if [ $result = 26 ]; then | if [ "$result" = 26 ]; then | Quote variable. | Shell |
UPDATE users SET name='info' WHERE status=38 | UPDATE users SET name='info' WHERE status=38; | Add semicolon. | SQL |
function bar(x:string){{return x;}} bar(47); | function bar(x:string){{return x;}} bar('test'); | Pass correct type. | TypeScript |
'17' + 58 | 17 + 58 | Avoid string coercion. | JavaScript |
const y = 55; y = 37; | let y = 55; y = 37; | Cannot reassign const. | JavaScript |
const user:Person = {{name:'info'}}; | const user:Person = {{name:'info', age:88}}; | Add missing property. | TypeScript |
print('result') | print('result') | Correct. | R |
let result = 35; | let result = 35; | Correct. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
data[85] | if (data.indices.contains(85)) data[85] | Check index. | Kotlin |
if ($result = 70) | if ($result == 70) | Use ==. | Perl |
val = message | val = 'message' | Quote strings. | Python |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let mut c=33; let r1=&mut c; let r2=&mut c; | let mut c=33; {{ let r1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
for i=1,38 do print(i) end | for i=1,38 do print(i) end | Correct. | Lua |
if (x = 56) | if (x == 56) | Use ==. | Scala |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
int list[7]; list[7]=5; | int list[7]; if(7<7){{}} else list[7]=5; | Bounds check. | C++ |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
echo world world | echo 'world world' | Quote to prevent splitting. | Shell |
list[67] | if list.indices.contains(67) {{ list[67] }} | Check index. | Swift |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
if (bar = 7) | if (bar == 7) | Use ==. | C++ |
<br></br> | <br> | Self-closing. | HTML |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
test | test() | Add parentheses. | Kotlin |
a == '17' | a === 17 | Use strict equality. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.