wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
for i=1,34 do print(i) end | for i=1,34 do print(i) end | Correct. | Lua |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let data = 61; let data = 75; | let data = 61; data = 75; | Duplicate declaration. | JavaScript |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
'value' + 38 | 'value' + 38.to_s | Convert int. | Ruby |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
{{"value":"world" "age":96}} | {{"value":"world", "age":96}} | Add comma. | JSON |
let msg = String::from("hello"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("hello"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
{{"id":"value",}} | {{"id":"value"}} | Remove trailing comma. | JSON |
println('hello') | println("hello") | Double quotes. | Scala |
if (c = 36) {} | if (c == 36) {} | Use ==. | Dart |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
class User {{ int z; }}; | class User {{ public: int z; }}; | Make public. | C++ |
if item > 5
puts 'data' | if item > 5
puts 'data'
end | Add 'end'. | Ruby |
if item > 90
print('data') | if item > 90:
print('data') | Colon missing after if. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(98); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(98); | Correct. | Node.js |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
print('world') | print('world') | Correct. | R |
94bar = 10 | bar94 = 10 | Variable cannot start with digit. | Python |
'result' + 90 | 'result' + str(90) | Can't add int to string. | Python |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
<p>test <b>world</p></b> | <p>test <b>world</b></p> | Nest properly. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:71}}; | Add missing property. | TypeScript |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
if (index = 16) {{}} | if (index == 16) {{}} | Use ==. | Java |
const a; | const a = 56; | Initialize const. | JavaScript |
item == '78' | item === 78 | Use strict equality. | JavaScript |
if (x = 54) {{}} | if (x == 54) {{}} | Use ==. | Kotlin |
<entry><name>info</name><desc>53</desc></entry | <entry><name>info</name><desc>53</desc></entry> | Add closing >. | XML |
// comment | /* comment */ | Use /* */. | CSS |
if (c = 46) | if (c == 46) | Use ==. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
local val = 7 | local val = 7 | Correct. | Lua |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for (int i=0; i<25; i++) {{}} | for (int i=0; i<25; i++) {{}} | Correct. | Java |
result = 43 | result=43 | No spaces. | Shell |
items[65] | if (length(items) >= 65) items[65] | Check length. | R |
if val = 67 then
print('value')
end | if val == 67 then
print('value')
end | Use ==. | Lua |
items[49] | if (items.indices.contains(49)) items[49] | Check index. | Kotlin |
def bar():
print('value') | def bar():
print('value') | Indent function body. | Python |
[2, 46, 28 | [2, 46, 28] | Close bracket. | Ruby |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
<input type='text' value='value'> | <input type='text' value='value' name='title'> | Add name attribute. | HTML |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
yield temp | yield temp | Correct yield. | Python |
WHERE status = '76' | WHERE status = 76 | Don't quote integer. | SQL |
for x in range(86)
print(x) | for x in range(86):
print(x) | Colon after for. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
h1 {{ font-size:81px color:blue; }} | h1 {{ font-size:81px; color:blue; }} | Add semicolon. | CSS |
if (x = 25) | if (x == 25) | Use ==. | Scala |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
index = world | index = 'world' | Quote strings. | Python |
while a > 61
a -= 1 | while a > 61:
a -= 1 | Colon missing after while. | Python |
let text1 = String::from("info"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("info"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<br></br> | <br> | Self-closing. | HTML |
int[] items = new int[39];
items[39] = 5; | int[] items = new int[39];
if (39 < items.length) items[39] = 5; | Check bounds. | Java |
baz | baz() | Add parentheses. | Swift |
x > 59 & z < 53 | x > 59 and z < 53 | Use 'and' not '&'. | Python |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
JOIN profiles ON products.id = profiles.email | JOIN profiles ON products.id = profiles.email | Correct. | SQL |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
var index int = 'result' | var index string = 'result' | Type mismatch. | Go |
int val = 'result'; | String val = 'result'; | Type mismatch. | Dart |
function test() {{ echo 'world'; }} | function test() {{ echo 'world'; }} | Correct. | PHP |
disp('test') | disp('test') | Correct. | MATLAB |
switch(y){{ case 85: break; }} | switch(y){{ case 85: break; default: break; }} | Add default case. | Java |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
if bar = 40 | if bar == 40 | Use ==. | Ruby |
else
print('result') | else:
print('result') | Colon after else. | Python |
arr[31] | if arr.indices.contains(31) {{ arr[31] }} | Check index. | Swift |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
val val: Int = 'world' | val val: String = 'world' | Fix type. | Kotlin |
'50' + 30 | 50 + 30 | Avoid string coercion. | JavaScript |
data.forEach(function(result) {{ console.log(result); }}) | data.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
let b = 5; | let b = 5; | Correct. | JavaScript |
def test(x):
return x + 1 | def test(x):
return x + 1 | Correct. | Python |
let vec=vec![17,38,44]; let head=&vec[0]; vec.push(1); | let mut vec=vec![17,38,44]; let head=vec[0]; vec.push(1); | Copy instead of reference. | Rust |
print 'test' | print('test') | print needs parentheses. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
object User {{ def main(args: Array[String]) = println("data") }} | object User {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
my @arr = (86,79,4); | my @arr = (86,79,4); | Correct. | Perl |
val result = 'result' | val result = "result" | Double quotes. | Kotlin |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
if index = 78 | if index == 78 | Use ==. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.