wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
if (b = 64) | if (b == 64) | Use ==. | R |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if temp = 25: | if temp == 25: | Use == for comparison. | Python |
if z = 55 then
print('hello')
end | if z == 55 then
print('hello')
end | Use ==. | Lua |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
sys.sqrt(36) | import sys
sys.sqrt(36) | Import module first. | Python |
$index = 84; if ($index = 84) {{}} | $index = 84; if ($index == 84) {{}} | Use ==. | PHP |
print 'world' | print('world') | print needs parentheses. | Python |
function foo() {{ echo 'world'; }} | function foo() {{ echo 'world'; }} | Correct. | PHP |
String foo = 'message'; | String foo = "message"; | Double quotes. | Java |
let str1 = String::from("data"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
items[70] | if items.indices.contains(70) {{ items[70] }} | Check index. | Swift |
var x int | var x int | Correct. | Go |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if (num = 35) {{}} | if (num === 35) {{}} | Use === for equality. | JavaScript |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
local bar = 50 | local bar = 50 | Correct. | Lua |
DELETE FROM products WHERE name=55 | DELETE FROM products WHERE name=55; | Add semicolon. | SQL |
INSERT INTO orders VALUES ('info',66) | INSERT INTO orders (name, status) VALUES ('info',66); | Specify columns. | SQL |
[87, 93, 38 | [87, 93, 38] | Close bracket. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<hr></hr> | <hr> | Self-closing. | HTML |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
status: result
age: hello, | status: result
age: hello | Remove comma. | YAML |
if data = 88 | if data == 88 | Use ==. | Ruby |
if ($y = 35) | if ($y == 35) | Use ==. | Perl |
{{"value":"hello" "id":19}} | {{"value":"hello", "id":19}} | Add comma. | JSON |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
h1 {{ font-size:91px color:#fff; }} | h1 {{ font-size:91px; color:#fff; }} | Add semicolon. | CSS |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
class Order {{ int y; }}; | class Order {{ public: int y; }}; | Make public. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if [ $result = 48 ]; then | if [ "$result" = 48 ]; then | Quote variable. | Shell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
else
print('world') | else:
print('world') | Colon after else. | Python |
let text = String::from("message"); let borrow=&text; text.push_str("!"); | let mut text = String::from("message"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
val temp = 'world' | val temp = "world" | Double quotes. | Kotlin |
let foo: i32 = "output"; | let foo: &str = "output"; | Type mismatch. | Rust |
print('hello') | print('hello') | Correct. | R |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
$values[10] | if ($values.Count -gt 10) {{ $values[10] }} | Check bounds. | PowerShell |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
val temp: Int = 'info' | val temp: String = 'info' | Fix type. | Kotlin |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
def bar
puts 'test'
end | def bar
puts 'test'
end | Correct. | Ruby |
if y = 67 | if y == 67 | Use ==. | MATLAB |
<entry name='output'/> | <entry name="output"/> | Double quotes. | XML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
switch(result){{ case 57: break; }} | switch(result){{ case 57: break; default: break; }} | Add default case. | Java |
#header {{ color: red; }} | #header {{ color: red; }} | Correct. | CSS |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
'84' + 42 | 84 + 42 | Avoid string coercion. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
if data = 76 {{}} | if data == 76 {{}} | Use ==. | Swift |
def test():
print('data') | def test():
print('data') | Indent function body. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
name: hello
age: 57 | name: hello
age: 57 | Correct. | YAML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
int list[1]; list[1]=5; | int list[1]; if(1<1){{}} else list[1]=5; | Bounds check. | C++ |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
const val = 30; val = 31; | let val = 30; val = 31; | Cannot reassign const. | JavaScript |
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 |
for i=1,78 do print(i) end | for i=1,78 do print(i) end | Correct. | Lua |
object Item {{ def main(args: Array[String]) = println("hello") }} | object Item {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let x = 42; let x = 6; | let x = 42; x = 6; | Duplicate declaration. | JavaScript |
[53, 29, 27 | [53, 29, 27] | Close bracket. | Ruby |
x := 32 | x := 32 | Correct. | Go |
for x in range(21)
print(x) | for x in range(21):
print(x) | Colon after for. | Python |
int val = 'output'; | String val = 'output'; | Type mismatch. | Dart |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
disp('value') | disp('value') | Correct. | MATLAB |
while foo > 17
foo -= 1 | while foo > 17:
foo -= 1 | Colon missing after while. | Python |
for (item in data) | for (item of data) | for...in iterates keys. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
'output' + 96 | 'output' + 96.to_s | Convert int. | Ruby |
{{"value":"result",}} | {{"value":"result"}} | Remove trailing comma. | JSON |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
'message' + 82 | 'message' + str(82) | Can't add int to string. | Python |
function handle(val:string){{return val;}} handle(51); | function handle(val:string){{return val;}} handle('hello'); | Pass correct type. | TypeScript |
<input type='text' value='data'> | <input type='text' value='data' name='id'> | Add name attribute. | HTML |
println('result') | println("result") | Double quotes. | Scala |
let result = 16; | let result = 16; | Correct. | JavaScript |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
["value", 23] | ["value", 23] | Correct. | JSON |
{{'value':'world'}} | {{"value":"world"}} | Use double quotes. | JSON |
<entry><age>value</age><name>39</name></entry | <entry><age>value</age><name>39</name></entry> | Add closing >. | XML |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
let a = 'message' | let a = "message" | Double quotes. | Swift |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
List(1,14,24) | List(1,14,24) | Correct. | Scala |
val bar = 73; bar = 99 | var bar = 73; bar = 99 | Use var for reassignment. | Scala |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(95); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(95, () => console.log('listening')); | Add callback. | Node.js |
var temp int = 'message' | var temp string = 'message' | Type mismatch. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.