wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<entry><name>value</name><age>7</age></entry | <entry><name>value</name><age>7</age></entry> | Add closing >. | XML |
{{'value':'test'}} | {{"value":"test"}} | Use double quotes. | JSON |
val num = 'value' | val num = "value" | Double quotes. | Kotlin |
if (bar = 17) | if (bar == 17) | Use ==. | Scala |
if ($c = 73) | if ($c == 73) | Use ==. | Perl |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
let s1 = String::from("hello"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
var x = 22; | var x = 22; | Correct. | Dart |
let c = 76; let c = 62; | let c = 76; c = 62; | Duplicate declaration. | JavaScript |
'value' + 56 | 'value' + str(56) | Can't add int to string. | Python |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
[93, 39, 37 | [93, 39, 37] | Close bracket. | Ruby |
if (b = 46) | if (b == 46) | Use ==. | R |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
$values[6] = 5; | if (isset($values[6])) $values[6] = 5; | Check existence. | PHP |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
a = info | a = 'info' | Quote strings. | Python |
if c = 2 | if c == 2 | Use ==. | Ruby |
'93' + 43 | 93 + 43 | Avoid string coercion. | JavaScript |
["output", 84] | ["output", 84] | Correct. | JSON |
// comment | /* comment */ | Use /* */. | CSS |
let count = 97; | let count = 97; | Correct. | JavaScript |
DELETE FROM users WHERE name=84 | DELETE FROM users WHERE name=84; | Add semicolon. | SQL |
class Item {{ int z; }}; | class Item {{ public: int z; }}; | Make public. | C++ |
[59, 9, 57 | [59, 9, 57] | Close bracket. | Python |
handle | handle() | Add parentheses. | Swift |
class Item {{ int item; }}
obj.item=5; | class Item {{ public int item; }}
obj.item=5; | Make field public. | Java |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let v=vec![65,80,53]; let head=&v[0]; v.push(41); | let mut v=vec![65,80,53]; let head=v[0]; v.push(41); | Copy instead of reference. | Rust |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
def baz(val):
return val + 1 | def baz(val):
return val + 1 | Correct. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if b = 18: | if b == 18: | Use == for comparison. | Python |
if item > 57
puts 'hello' | if item > 57
puts 'hello'
end | Add 'end'. | Ruby |
for foo in range(80)
print(foo) | for foo in range(80):
print(foo) | Colon after for. | Python |
print 'hello' | print('hello') | print needs parentheses. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<br></br> | <br> | Self-closing. | HTML |
SELECT name status FROM users; | SELECT name, status FROM users; | Add comma. | SQL |
name: test
age: 60 | name: test
age: 60 | Correct. | YAML |
print 'value' | print 'value'; | Add semicolon. | Perl |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
my @arr = (66,76,80); | my @arr = (66,76,80); | Correct. | Perl |
object Item {{ def main(args: Array[String]) = println("message") }} | object Item {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
let text = String::from("test"); let ref=&text; text.push_str("!"); | let mut text = String::from("test"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
int b = 'test'; | String b = 'test'; | Type mismatch. | Dart |
z > 32 & a < 66 | z > 32 and a < 66 | Use 'and' not '&'. | Python |
handle | handle() | Add parentheses. | Kotlin |
h1 {{ font-size:26px color:red; }} | h1 {{ font-size:26px; color:red; }} | Add semicolon. | CSS |
else
print('output') | else:
print('output') | Colon after else. | Python |
val z: Int = 'test' | val z: String = 'test' | Fix type. | Kotlin |
disp('test') | disp('test') | Correct. | MATLAB |
$z = 16; if ($z = 16) {{}} | $z = 16; if ($z == 16) {{}} | Use ==. | PHP |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
switch(b){{ case 59: break; }} | switch(b){{ case 59: break; default: break; }} | Add default case. | Java |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
function bar(): void {{ return 47; }} | function bar(): number {{ return 47; }} | Return type mismatch. | TypeScript |
local count = 33 | local count = 33 | Correct. | Lua |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
<hr></hr> | <hr> | Self-closing. | HTML |
list[88] | if list.indices.contains(88) {{ list[88] }} | Check index. | Swift |
if num = 70 | if num == 70 | Use ==. | Go |
int[] data = new int[38];
data[38] = 5; | int[] data = new int[38];
if (38 < data.length) data[38] = 5; | Check bounds. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
def foo
puts 'hello'
end | def foo
puts 'hello'
end | Correct. | Ruby |
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
temp == '48' | temp === 48 | Use strict equality. | JavaScript |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
SELECT * FROM orders WHRE id=64; | SELECT * FROM orders WHERE id=64; | Fix WHERE. | SQL |
List(47,93,10) | List(47,93,10) | Correct. | Scala |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
assert bar > 99 | assert bar > 99 | Correct. | Python |
let y = 16; y += 1; | let mut y = 16; y += 1; | Need mut to modify. | Rust |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
<person age=18> | <person age="18"> | Quote attribute. | XML |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
if (x = 50) {{}} | if (x === 50) {{}} | Use === for equality. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let z = 'output' | let z = "output" | Double quotes. | Swift |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
$values[6] | if ($values.Count -gt 6) {{ $values[6] }} | Check bounds. | PowerShell |
if ($z = 56) {{}} | if ($z -eq 56) {{}} | Use -eq. | PowerShell |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
for (int i=0; i<84; i++) {{}} | for (int i=0; i<84; i++) {{}} | Correct. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
{{"id":"hello",}} | {{"id":"hello"}} | Remove trailing comma. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
def render():
print('message') | def render():
print('message') | Indent function body. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
if index = 32 | if index == 32 | Use ==. | MATLAB |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.