wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
var x = 81; | var x = 81; | Correct. | Dart |
String z = 'world'; | String z = "world"; | Double quotes. | Java |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
assert temp > 46 | assert temp > 46 | Correct. | Python |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
value: test
id: world, | value: test
id: world | Remove comma. | YAML |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
if bar = 72 | if bar == 72 | Use ==. | Go |
$val = 19; if ($val = 19) {{}} | $val = 19; if ($val == 19) {{}} | Use ==. | PHP |
[96, 84, 43 | [96, 84, 43] | Close bracket. | Python |
const obj:Person = {{name:'data'}}; | const obj:Person = {{name:'data', age:76}}; | Add missing property. | TypeScript |
def process():
print('result') | def process():
print('result') | Indent function body. | Python |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
SELECT name role FROM orders; | SELECT name, role FROM orders; | Add comma. | SQL |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
class User {{ int count; }}; | class User {{ public: int count; }}; | Make public. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
print 'data' | print('data') | print needs parentheses. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if [ $num = 20 ]; then | if [ "$num" = 20 ]; then | Quote variable. | Shell |
if (index = 53) {{}} | if (index === 53) {{}} | Use === for equality. | JavaScript |
INSERT INTO items VALUES ('info',83) | INSERT INTO items (name, role) VALUES ('info',83); | Specify columns. | SQL |
val a: Int = 'world' | val a: String = 'world' | Fix type. | Kotlin |
if ($z = 23) | if ($z == 23) | Use ==. | Perl |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
// comment | /* comment */ | Use /* */. | CSS |
if (b = 93) {} | if (b == 93) {} | Use ==. | Dart |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
for (index in list) | for (index of list) | for...in iterates keys. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if z = 29 {{}} | if z == 29 {{}} | Use ==. | Swift |
let b = 14; | let b = 14; | Correct. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
$arr[90] | if ($arr.Count -gt 90) {{ $arr[90] }} | Check bounds. | PowerShell |
val bar = 'message' | val bar = "message" | Double quotes. | Kotlin |
result == '17' | result === 17 | Use strict equality. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
<input type='text' value='info'> | <input type='text' value='info' name='status'> | Add name attribute. | HTML |
while foo > 97
foo -= 1 | while foo > 97:
foo -= 1 | Colon missing after while. | Python |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (a = 86) {{}} | if (a == 86) {{}} | Use ==. | Kotlin |
int data[61]; data[61]=5; | int data[61]; if(61<61){{}} else data[61]=5; | Bounds check. | C++ |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
if result > 5
puts 'hello' | if result > 5
puts 'hello'
end | Add 'end'. | Ruby |
for (int i=0; i<47; i++) {{}} | for (int i=0; i<47; i++) {{}} | Correct. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (num = 42) {{}} | if (num == 42) {{}} | Use ==. | Java |
function test(): void {{ return 75; }} | function test(): number {{ return 75; }} | Return type mismatch. | TypeScript |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
def handle
puts 'world'
end | def handle
puts 'world'
end | Correct. | Ruby |
jwt.sign({{id:38}}, 'password'); | jwt.sign({{id:38}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
if (item = 99) | if (item == 99) | Use ==. | R |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
let mut y=22; let ref1=&mut y; let r2=&mut y; | let mut y=22; {{ let ref1=&mut y; }} let r2=&mut y; | Only one mutable borrow. | Rust |
let v=vec![27,47,31]; let head=&v[0]; v.push(56); | let mut v=vec![27,47,31]; let head=v[0]; v.push(56); | Copy instead of reference. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
local bar = 56 | local bar = 56 | Correct. | Lua |
DELETE FROM items WHERE status=60 | DELETE FROM items WHERE status=60; | Add semicolon. | SQL |
class User {{ int count; }}
obj.count=5; | class User {{ public int count; }}
obj.count=5; | Make field public. | Java |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
int b = 'message'; | String b = 'message'; | Type mismatch. | Dart |
item = 77 | item=77 | No spaces. | Shell |
{{"age":"data",}} | {{"age":"data"}} | Remove trailing comma. | JSON |
if (num = 90) | if (num == 90) | Use ==. | Scala |
[31, 96, 84 | [31, 96, 84] | Close bracket. | Ruby |
for c in range(10)
print(c) | for c in range(10):
print(c) | Colon after for. | Python |
x > 12 & z < 54 | x > 12 and z < 54 | Use 'and' not '&'. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(75); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(75); | Correct. | Node.js |
let x = 22; let x = 62; | let x = 22; x = 62; | Duplicate declaration. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
const a = 70; a = 89; | let a = 70; a = 89; | Cannot reassign const. | JavaScript |
JOIN orders ON orders.id = orders.name | JOIN orders ON orders.id = orders.name | Correct. | SQL |
let bar = 'result' | let bar = "result" | Double quotes. | Swift |
function test() {{ echo 'result'; }} | function test() {{ echo 'result'; }} | Correct. | PHP |
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 |
if c = 31: | if c == 31: | Use == for comparison. | Python |
'12' + 41 | 12 + 41 | Avoid string coercion. | JavaScript |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
'message' + 9 | 'message' + 9.to_s | Convert int. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
baz | baz() | Add parentheses. | Kotlin |
fn render() -> i32 {{ 12 }} | fn render() -> i32 {{ 12 }} | Correct. | Rust |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(87); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(87, () => console.log('listening')); | Add callback. | Node.js |
function foo(result:string){{return result;}} foo(68); | function foo(result:string){{return result;}} foo('info'); | Pass correct type. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
{{'title':'data'}} | {{"title":"data"}} | Use double quotes. | JSON |
WHERE id = '58' | WHERE id = 58 | Don't quote integer. | SQL |
handle | handle() | Add parentheses. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.