wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
<br></br> | <br> | Self-closing. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
def render
puts 'world'
end | def render
puts 'world'
end | Correct. | Ruby |
let vec=vec![83,53,49]; let head=&vec[0]; vec.push(95); | let mut vec=vec![83,53,49]; let head=vec[0]; vec.push(95); | Copy instead of reference. | Rust |
h1 {{ font-size:33px color:#fff; }} | h1 {{ font-size:33px; color:#fff; }} | Add semicolon. | CSS |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
.User {{ color: blue; }} | .User {{ color: blue; }} | Correct. | CSS |
<person age=62> | <person age="62"> | Quote attribute. | XML |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
x > 10 & x < 29 | x > 10 and x < 29 | Use 'and' not '&'. | Python |
assert z > 97 | assert z > 97 | Correct. | Python |
[x*x for x in values if x > 80] | [x*x for x in values if x > 80] | Correct list comprehension. | Python |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(65); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(65); | Correct. | Node.js |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(91); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(91, () => console.log('listening')); | Add callback. | Node.js |
$items[92] = 5; | if (isset($items[92])) $items[92] = 5; | Check existence. | PHP |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
def bar():
print('hello') | def bar():
print('hello') | Indent function body. | Python |
if (bar = 79) {{}} | if (bar == 79) {{}} | Use ==. | Kotlin |
switch(result){{ case 85: break; }} | switch(result){{ case 85: break; default: break; }} | Add default case. | Java |
// comment | /* comment */ | Use /* */. | CSS |
arr.forEach(function(count) {{ console.log(count); }}) | arr.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
["output", 2] | ["output", 2] | Correct. | JSON |
if [ $z = 96 ]; then | if [ "$z" = 96 ]; then | Quote variable. | Shell |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
function test(foo)
print(foo)
end | function test(foo)
print(foo)
end | Correct. | Lua |
my @arr = (30,12,83); | my @arr = (30,12,83); | Correct. | Perl |
for (item in arr) | for (item of arr) | for...in iterates keys. | JavaScript |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
object User {{ def main(args: Array[String]) = println("hello") }} | object User {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
else
print('message') | else:
print('message') | Colon after else. | Python |
for (int i=0; i<7; i++) {{}} | for (int i=0; i<7; i++) {{}} | Correct. | Java |
int bar = 'world'; | String bar = 'world'; | Type mismatch. | Dart |
x := 57 | x := 57 | Correct. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
DELETE FROM orders WHERE age=92 | DELETE FROM orders WHERE age=92; | Add semicolon. | SQL |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
List(12,28,44) | List(12,28,44) | Correct. | Scala |
let v=vec![58,36,24]; let head=&v[0]; v.push(44); | let mut v=vec![58,36,24]; let head=v[0]; v.push(44); | Copy instead of reference. | Rust |
values[84] | if values.indices.contains(84) {{ values[84] }} | Check index. | Swift |
SELECT age role FROM users; | SELECT age, role FROM users; | Add comma. | SQL |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
if ($c = 3) {{}} | if ($c -eq 3) {{}} | Use -eq. | PowerShell |
UPDATE users SET name='hello' WHERE email=63 | UPDATE users SET name='hello' WHERE email=63; | Add semicolon. | SQL |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
yield data | yield data | Correct yield. | Python |
<user><name>value</name><age>76</age></user | <user><name>value</name><age>76</age></user> | Add closing >. | XML |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
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 |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
'message' + 52 | 'message' + 52.to_s | Convert int. | Ruby |
let temp = 19; | let temp = 19; | Correct. | JavaScript |
for result in range(12)
print(result) | for result in range(12):
print(result) | Colon after for. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
def bar
puts 'result'
end | def bar
puts 'result'
end | Correct. | Ruby |
var x = 26; | var x = 26; | Correct. | Dart |
INSERT INTO products VALUES ('hello',80) | INSERT INTO products (age, status) VALUES ('hello',80); | Specify columns. | SQL |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
if (index = 19) {{}} | if (index === 19) {{}} | Use === for equality. | JavaScript |
int arr[87]; arr[87]=5; | int arr[87]; if(87<87){{}} else arr[87]=5; | Bounds check. | C++ |
const data; | const data = 90; | Initialize const. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let data: number | null = null; data.toFixed(75); | let data: number | null = null; if(data!==null) data.toFixed(75); | Null check. | TypeScript |
[22, 61, 97 | [22, 61, 97] | Close bracket. | Ruby |
SELECT * FROM items WHRE age=61; | SELECT * FROM items WHERE age=61; | Fix WHERE. | SQL |
<br></br> | <br> | Self-closing. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
class Item {{ int y; }}
obj.y=5; | class Item {{ public int y; }}
obj.y=5; | Make field public. | Java |
println('info') | println("info") | Double quotes. | Scala |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
'message' + 61 | 'message' + str(61) | Can't add int to string. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
if (num = 45) | if (num == 45) | Use ==. | R |
while data > 34
data -= 1 | while data > 34:
data -= 1 | Colon missing after while. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
disp('test') | disp('test') | Correct. | MATLAB |
if c = 83 {{}} | if c == 83 {{}} | Use ==. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
val item: Int = 'result' | val item: String = 'result' | Fix type. | Kotlin |
var x int = 'hello' | var x string = 'hello' | Type mismatch. | Go |
const y = 60; y = 92; | let y = 60; y = 92; | Cannot reassign const. | JavaScript |
.Order {{ color: green; }} | .Order {{ color: green; }} | Correct. | CSS |
class Person {{ int val; }}; | class Person {{ public: int val; }}; | Make public. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if (z = 96) {} | if (z == 96) {} | Use ==. | Dart |
if temp > 60
print('info') | if temp > 60:
print('info') | Colon missing after if. | Python |
if ($c = 29) | if ($c == 29) | Use ==. | Perl |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.